dns-323 scripts - login status info, etc
Published October 27th, 2008 in dns-323, hacks, unix
Wouldn’t it be handy to get some vital stats from your dlink dns-323 when you login via telnet or ssh?
you can, with this script… (assuming you’ve installed fonz’s funplug 0.5)
I’ve posted (and will continue to post) my d-link dns-323 scripts here. All that I ask is if you decide to use or customize them, that you give me some credit — and contribute your tweaks back to me in the comments
cd /ffp/etc/profile.d/
vi login_status.sh
<paste script below>
<save, logout, log back in>
#!/ffp/bin/sh
##############################################################################
# login_status.sh
# A script to show some status/diagnostic info when you log into the console.
# w 10/27/08 horto
##############################################################################alias w=who
# lastlog
echo “—[ last dmesg log ]—”
dmesg | tail -3
echo”"# print disk status
echo “—[ disk status ]—”
dns323-spindown
echo “”# show load averages, cpu load, free mem, etc
echo “—[ system resources ]—”
top -n 1 -b | head -3
echo “”
# show temps
echo “—[ temps ]—”
echo “`dns323-temp` fanspeed: `dns323-fan`”
echo “”# show hdd space avail
echo “—[ hdd space used/avail/used% ]—”
df -h | grep HD_[ab]2 | awk ‘{print $6, $3, $4, $5}’
#df -k | grep HD_[ab]2 | awk ‘{print $6, $5}’
echo “”
output is:
login as: root
Server refused our key
root@192.168.1.128’s password:
—[ last dmesg log ]—
#######################################
# HD0 awake now ! #
#######################################
—[ disk status ]—
[03] hd0 hd1
[01] ACTIVE
—[ system resources ]—
Mem: 60772K used, 1176K free, 0K shrd, 10960K buff, 33260K cached
CPU: 0% usr 8% sys 0% nice 0% idle 83% io 0% irq 8% softirq
Load average: 1.07 0.98 1.03
—[ temps ]—
44 C 111 F fanspeed: 2700 2700 0
—[ hdd space used/avail/used% ]—
/mnt/HD_a2 8.2G 907.7G 1%
/mnt/HD_b2 12.5G 903.4G 1%
root@blinky:~#
yet another great script thanks Horto
I’ve used wget to dwnld the script u’ve created.
How do i make it bootable?
For those who would like a fancy prompt try this
vi /mnt/HD_a2/ffp/etc/profile.d/root-prompt.sh
HOSTNAME=`hostname`
DARKBLUE=”\[33[0;34m\]”
MAGENTA=”\[33[0;35m\]”
BLANK=”\[33[0m\]”
BRIGHTYELLOW=”\[33[1;33m\]”
LIGHTGREEN=”\[33[1;32m\]”
CYAN=”\[33[0;36m\]”
BLUE=”\[33[1;34m\]”
ENVIRONMENT=${MAGENTA}
PS1=”${LIGHTGREEN}[${ENVIRONMENT}$HOSTNAME${BLUE}:${CYAN}\w${LIGHTGREEN}]\n${DARKBLUE}${BLUE}(${BLANK}\u${BLANK}${BLUE})${BRIGHTYELLOW}>${BLANK}”
save (wq!)
chmod a+x /mnt/HD_a2/ffp/etc/profile.d/root-prompt.sh and re-login
One little detail is missing - script has to be executable. It is obvious to some, it’s not so easy to somebody else
Dear Andy!
Your scripts doesn’t work for me.
I am totally newbie so tell me the missing steps.
Thanks your work!
C.
Cirip, did you vi that file and then copy and paste in what I have? All you should need is to do that, then make the file executable as mrskhris pointed out (chmod 755 /mnt/HD_a2/ffp/etc/profile.d/root-prompt.sh) and then re-login and the prompt will change (givin you are using a terminal that can handle ansi colors etc)
Andy
Andy, I see this:
33[1;32m[33[0;35mdlink-96D7E133[1;34m:33[0;36m~33[1;32m]
33[0;34m33[1;34m(33[0mroot33[0m33[1;34m)33[1;33m>33[0mmc
I use putty and I see the mc in color.
do
echo $TERM and see what it comes back with, in putty try setting your term to “linux” or once you login to your nas type export TERM=linux and then run sh /mnt/HD_a2/ffp/etc/profile.d/root-prompt.sh
Andy
Hi Andy!
I use TERM=xterm because my mc works correctly only with xterm value (the function buttons)
But I tried if I use TERM=linux the promt was:
33[1;32m[33[0;35mdlink-96D7E133[1;34m:33[0;36m~33[1;32m]
33[0;34m33[1;34m(33[0mroot33[0m33[1;34m)33[1;33m>33[0mmc
so nothing changed.
Crisp, the only thing I can think of is your copy is getting messed up try this,
cd /mnt/HD_a2/ffp/etc/profile.d/
rm root-prompt.sh
wget http://mentges.net/root-prompt.sh
chmod 755 root-prompt.sh
Andy
Thanks Andy!
It is works! The problem was maybe with the caracter-sets.
Best regards!
make the script bootable by issuing the following command:
chmod +x /ffp/etc/profile.d/login_status.sh
How are the profile.d scripts actually executed when I login?
I’m using ffp-0.5 on the DNS323 with firmware 1.04 but I cannot get the login_status script to work. It is executable and placed in /ffp/etc/profile.d directory. I also tried installing bash and I changed my default shell to bash but when I login the script isn’t run.
Any ideas?
@Uyuni: Not sure dude. It should “just work”. Anything executable in /ffp/etc/profile.d/ should just run. Can you confirm that #!/ffp/bin/sh is the very first line in the file? This is important. And that /ffp/bin/sh exists on your system?
what login & pass i must type?
what default pass?
i can’t login
thenx
It works fine when I use ssh login but it doesn’t work with telnet login via the standard installed ffp. Is it working for you with telnet?
my profile didn’t source the profile.d scripts. add this to your /ffp/etc/profile file at the bottom:
# include custom profile files
for profile_script in /ffp/etc/profile.d/*.sh; do
if [ -x $profile_script ]; then
. $profile_script
fi
done
unset profile_script
Is it normal to get such messages as:
—[ last dmesg log ]—
ext3: No journal on filesystem on sdb2
ext3: No journal on filesystem on sda4
ext3: No journal on filesystem on sdb4
This is on a fresh reformat and funplug installation.
Hi, i just started in linux worrld and i french for my first language.
I have a DNS-323, and i wont changing the defauly user for choosing another user and password but i dont know do that for this … !
If you help to me to take control to my NAS, i hope for the response to you.
I’m very not have idea for make that.
Atomas17