Code Sample |
#!/bin/sh echo Starting r00t_l00p... # This script adds some super-user functionality to regular # old Wendy Whitebread accounts. # # What it does is check for certain directory names in /tmp, # then acts on whatever it finds there. So other programs, and # the user, can communicate with it via `mkdir' or a launcher # button that runs a simple `mikdir /tmp/r00t/foo' command. mkdir -p /tmp/r00t/run chmod -R 777 /tmp/r00t sleep 11 rm -rf /tmp/r00t/run # # If the `run' folder exists, this indicates that a r00t script # has just been started, and other instances should quit now. # # Avoids multiple instances piling up from one login to the next. while : do if [ -x /tmp/r00t/run ] then echo Ending r00t_l00p. exit 0 # What did I just say? elif [ -x /tmp/r00t/shutdown ] #### Unused, but I might need these sometime... then rm -rf /tmp/r00t/shutdown killall sleep sudo -u moi xmms -s sleep 2 shutdown -P now "Thassal, Folks!" elif [ -x /tmp/r00t/reboot ] then rm -rf /tmp/r00t/reboot killall sleep sudo -u moi xmms -s sleep 2 shutdown -r now "Back in a bit..." elif [ -x /tmp/r00t/hibernate ] #### But I do need this, because the standard #### `Hibernate' button never works in Xubuntu... then rm -rf /tmp/r00t/hibernate sudo -u moi xmms -s sleep 1 umount /dev/sda1 /etc/acpi/hibernate.sh # # Requires the addition of an `&' in # /etc/acpi/hibernate.sh # # Here, on the last line; # . /etc/acpi/resume.sh & # # Otherwise, the hibernate script will just sit there # and wait, long after it's finished its work, and so # will r00t_l00p; waiting for hibernate.sh to exit. # And on resume; # sudo -u moi mount /dev/sda1 mount /dev/sda1 sleep 7 sudo -u moi xmms -p elif [ -x /tmp/r00t/insomnia ] #### Makes `sleep'-deferred actions happen now #### In other words; `Procrastinate Later'. then rm -rf /tmp/r00t/insomnia killall sleep elif [ -x /tmp/r00t/ftp-stat ] #### Server status then rm -rf /tmp/r00t/ftp-stat if [ -x /tmp/r00t/ftp-on ] then xterm -title '::0N::' \ -geometry 28x3 -e 'echo && echo \ " FTP Server is ON." && echo -n \ " " && sleep 3' & # # Woohoo! GUI notification dialogs # from a shell script! elif [ -x /tmp/r00t/ftp-off ] then xterm -title '::0FF::' \ -geometry 28x3 -e 'echo && echo \ " FTP Server is OFF." && echo -n \ " " && sleep 3' & # " [press any key to " && echo -n \ # " close window] " && read -n 1' & fi elif [ -x /tmp/r00t/ftp-switch ] #### Turn the server on or off then rm -rf /tmp/r00t/ftp-switch if [ -x /tmp/r00t/ftp-on ] #### If it's on, stop it then xterm -title '::0FF::' \ -geometry 28x3 -e 'echo && echo \ " Stopping FTP Server." && echo -n \ " " && sleep 3' & mv /tmp/r00t/ftp-on /tmp/r00t/ftp-off /etc/init.d/proftpd stop /etc/init.d/proftpd force-stop sleep 3 killall -s 9 proftpd elif [ -x /tmp/r00t/ftp-off ] #### If it's off, start it then xterm -title '::0N::' \ -geometry 28x3 -e 'echo && echo \ " Starting FTP Server." && echo -n \ " " && sleep 3' & mv /tmp/r00t/ftp-off /tmp/r00t/ftp-on /etc/init.d/proftpd start elif [ -x /tmp/r00t ] #### And if you don't know, stop it anyway then mkdir -p /tmp/r00t/ftp-off /etc/init.d/proftpd stop /etc/init.d/proftpd force-stop sleep 3 killall -s 9 proftpd fi fi sleep 3 done |
Quote (the Missing M @ May 11 2007,07:11) |
However, since this is a laptop, I do want to be sure the FTP daemon's really, truly and completely shut down.. |
Quote (humpty @ May 10 2007,19:03) |
you can do a grep on a ps to a temp file. if the file is emtpy, then it's a gonna. |
Code Sample |
x=`ps -e|grep proftpd` if [[ $x = "" ]]; then echo phoo; else echo $x; fi |
Code Sample |
#!/bin/sh echo Starting r00t_l00p... # This script adds some super-user functionality to regular # old Wendy Whitebread accounts. # # What it does is check for certain directory names in /tmp, # then acts on whatever it finds there. So other programs, and # the user, can communicate with it via `mkdir' or a launcher # button that runs a simple `mkdir /tmp/r00t/foo' command. mkdir -p /tmp/r00t/run chmod -R 777 /tmp/r00t sleep 11 rm -rf /tmp/r00t/run # # If the `run' folder exists, this indicates that a r00t script # has just been started, and other instances should quit now. # # Avoids multiple instances piling up from one login to the next. while : do sleep 2 if [ -d /tmp/r00t/run ] then echo Ending r00t_l00p. exit 0 # What did I just say? elif [ -d /tmp/r00t/shutdown ] #### Unused, but I might need these sometime... then rm -rf /tmp/r00t/shutdown killall sleep sudo -u moi xmms -s sleep 2 shutdown -P now "Thassal, Folks!" elif [ -d /tmp/r00t/reboot ] then rm -rf /tmp/r00t/reboot killall sleep sudo -u moi xmms -s sleep 2 shutdown -r now "Back in a bit..." elif [ -d /tmp/r00t/hibernate ] #### But I do need this, because the standard #### `Hibernate' button never works in Xubuntu... then rm -rf /tmp/r00t/hibernate sudo -u moi xmms -s sleep 1 umount /dev/sda1 /etc/acpi/hibernate.sh # # Requires the addition of an `&' in # /etc/acpi/hibernate.sh # # Here, on the last line; # . /etc/acpi/resume.sh & # # Otherwise, the hibernate script will just sit there # and wait, long after it's finished its work. And so # will r00t_l00p; waiting for hibernate.sh to exit. # And on resume; # sudo -u moi mount /dev/sda1 mount /dev/sda1 sleep 7 sudo -u moi xmms -p elif [ -d /tmp/r00t/insomnia ] #### Makes `sleep'-deferred actions happen now then rm -rf /tmp/r00t/insomnia killall sleep elif [ -d /tmp/r00t/ppp-switch ] then rm -rf /tmp/r00t/ppp-switch if [ "`ps -e | grep pppd`" = "" ] then pon Primus.ca else poff -a fi elif [ -d /tmp/r00t/ftp-stat ] #### Server status then rm -rf /tmp/r00t/ftp-stat if [ "`ps -e | grep proftpd`" = "" ] then xterm -title '::0FF::' \ -geometry 28x3 -e 'echo; echo \ " FTP Server is OFF." ; echo -n \ " " ; sleep 2' & # # Woohoo! GUI notification # dialogs from the shell! else xterm -title '::0N::' \ -geometry 28x3 -e 'echo; echo \ " FTP Server is ON." ; echo -n \ " " ; sleep 2' & # " [press any key to " ; echo -n \ # " close window] " ; read -n 1' & fi elif [ -d /tmp/r00t/ftp-switch ] #### Turn the server on or off then rm -rf /tmp/r00t/ftp-switch if [ "`ps -e | grep proftpd`" = "" ] #### If it's off, start it then xterm -title '::0N::' \ -geometry 28x3 -e 'echo; echo \ " Starting FTP Server." ; echo -n \ " " ; sleep 3' & /etc/init.d/proftpd start sleep 2 if [ "`ps -e | grep proftpd`" = "" ] then xterm -title '::FA1L::' \ -geometry 28x6 -e 'echo; echo \ " Server would not start."; echo; echo \ " [press any key" ; echo \ " to proceed]" ; echo -n \ " "; read -n 1' sh -c 'cd /etc/init.d; \ xfce4-terminal -T "F1X PR0FTPD"' & fi else #### If it's on, stop it xterm -title '::0FF::' \ -geometry 28x3 -e 'echo; echo \ " Stopping FTP Server." ; echo -n \ " " ; sleep 3' & /etc/init.d/proftpd stop sleep 1 if [ "`ps -e | grep proftpd`" = "" ] then xterm -title '::0FF::' \ -geometry 28x3 -e 'echo; echo \ " Stopped FTP Server." ; echo -n \ " " ; sleep 3' & else /etc/init.d/proftpd force-stop sleep 1 if [ "`ps -e | grep proftpd`" = "" ] then xterm -title '::0FF::' \ -geometry 28x3 -e 'echo; echo \ " Stopped FTP Server." ; echo -n \ " " ; sleep 3' & else killall -s 9 proftpd sleep 1 if [ "`ps -e | grep proftpd`" = "" ] then xterm -title '::0FF::' \ -geometry 28x3 -e 'echo; echo \ " Stopped FTP Server." ; echo -n \ " " ; sleep 3' & else xterm -title '::FA1L::' \ -geometry 28x6 -e 'echo; echo \ " WTF? Unkillable..." ; echo; echo \ " [press any key to" ; echo \ " close window]"; echo -n \ " " ; read -n 1' & fi fi fi fi fi done |
Quote |
BTW, does anyone know how to make grep match only whole words, and ignore word fragments like the `proftpd' in `gproftpd'? |