August 20, 200817 yr I do know one thing for sure, the "init 0" to power off the machine will not happen. You brought up some interesting food for thought. I've been considering the addition of scripts (or hooks) for /etc/rc.d/rc.0 There is a block in this code for # Run any local shutdown scripts: if [ -x /etc/rc.d/rc.local_shutdown ]; then /etc/rc.d/rc.local_shutdown stop fi I could possibly add the proper graceful unraid shutdown commands in there. PS> Funny Story Joe! I've made that init 1 mistake too!
August 20, 200817 yr # Run any local shutdown scripts: if [ -x /etc/rc.d/rc.local_shutdown ]; then /etc/rc.d/rc.local_shutdown stop fi I could possibly add the proper graceful unraid shutdown commands in there. Looks perfect for a few commands to stop the array cleanly.
August 20, 200817 yr I've been considering the addition of scripts (or hooks) for /etc/rc.d/rc.0 There is a block in this code for # Run any local shutdown scripts: if [ -x /etc/rc.d/rc.local_shutdown ]; then /etc/rc.d/rc.local_shutdown stop fi I'm thinking you really mean the file rc.6? Would it just change to this? # Run any local shutdown scripts: if [ -x /etc/rc.d/rc.local_shutdown ]; then /sbin/powerdown /etc/rc.d/rc.local_shutdown stop fi The powerdown script then should really be without these lines, correct? # /sbin/poweroff logger "Initiating Shutdown with Halt" /sbin/shutdown -t5 -h now I guess in reality it wouldn't really matter either way except the script would then no longer perform a command prompt shutdown. I'll take a closer look at Joe's fix after I do some more reading and then get home so I can actually play with the system. Peter
August 20, 200817 yr >> Would it just change to this? # Run any local shutdown scripts: if [ -x /etc/rc.d/rc.local_shutdown ]; then /sbin/powerdown /etc/rc.d/rc.local_shutdown stop fi No, Actually what I'm considering to to is take apart (or pieces of) the powerdown command and put them inside /etc/rc.d/rc.local_shutdown Main pieces are. 1. Stopping samba(so I do it twice, no biggie) and nfs. 1. Killing processes that are active on the filesystem. 2. umounting the partitions on /mnt. 3. stopping the array via mdcmd. 4. saving syslog. rc0 and rc6 are the same script. root@Atlas:/mnt/disk2# ls -l /etc/rc.d/rc.0 /etc/rc.d/rc.6 lrwxrwxrwx 1 root root 4 Aug 12 22:23 /etc/rc.d/rc.0 -> rc.6* -rwxr-xr-x 1 root root 7358 Aug 12 22:23 /etc/rc.d/rc.6* One halts, one reboots, It's based on the script name(ext) see code echo "Running shutdown script $0:" # Find out how we were called. case "$0" in *0) command="halt" ;; *6) command=reboot ;; *) echo "$0: call me as \"rc.0\" or \"rc.6\" please!" exit 1 ;; esac >> The powerdown script then should really be without these lines, correct? I don't know at this moment. I have to think about this s'more.
August 20, 200817 yr Would it just change to this? # Run any local shutdown scripts: if [ -x /etc/rc.d/rc.local_shutdown ]; then /sbin/powerdown /etc/rc.d/rc.local_shutdown stop fi No, that then says "If the /etc/rc.d.local_shutdown command exists and is execuitable" "then" run /sbin/powerdown followd by /etc/rc.d/local_shutdown stop end if Since we do not have a file named /etc/rc.d/rc.local_shutdown, (and it is certainly not execuitible if it does not exist) nothing would ever call /sbin/powerdown. My one line "sed" edit of the acpi_handler.sh script will act as desired for the power button, assuming of course, that the acpi handler is functional. (and it appears to be in your case, since it did shut down the server, but used init 0 when it did.) Joe L.
August 20, 200817 yr My one line "sed" edit of the acpi_handler.sh script will act as desired for the power button, assuming of course, that the acpi handler is functional. (and it appears to be in your case, since it did shut down the server, but used init 0 when it did.) The sed line will work. I think in the long run, adding the proper blocks to the /etc/rc.d/local_shutdown script is the best way to go. This would add the proper functionality for runlevel 0 (poweroff) or runlevel 6 (reboot) Perhaps I'll create an /etc/rc.d/rc.unRAID script with arg 1 being stop or start. Then add the call of this to /etc/rc.d/local_shutdown. I think if it's done this way we would not need the poweroff command.
August 20, 200817 yr My one line "sed" edit of the acpi_handler.sh script will act as desired for the power button, assuming of course, that the acpi handler is functional. (and it appears to be in your case, since it did shut down the server, but used init 0 when it did.) The sed line will work. I think in the long run, adding the proper blocks to the /etc/rc.d/local_shutdown script is the best way to go. This would add the proper functionality for runlevel 0 (poweroff) or runlevel 6 (reboot) Perhaps I'll create an /etc/rc.d/rc.unRAID script with arg 1 being stop or start. Then add the call of this to /etc/rc.d/local_shutdown. I think if it's done this way we would not need the poweroff command. I think you are right. My "sed" edit only addresses the ACPI handling of the power button. There are so many possible ways to shut down the machine. Your idea of the rc.local_shutdown script will catch more than most. If we are lucky, even catch a quickly typed "init q" Joe L.
August 21, 200817 yr I get it now - I think anyways. It just takes a while I didn't realize that rc.local_shutdown didn't exist. So, would we not more or less use the powerdown script and move it to /etc/rc.d/rc.local_shutdown then chmod it to be executable on boot? I realize it is a little more complex since this script has to accept the stop argument but that's the basic idea, correct? The sed line does work so I've got a powerbutton shutdown now. Peter
August 21, 200817 yr [quote name="lionelhutz" post="18316" timestamp="1219283830"] I didn't realize that rc.local_shutdown didn't exist. So, would we not more or less use the powerdown script and move it to /etc/rc.d/rc.local_shutdown then chmod it to be executable on boot? There is still work to go. I have to see how to set up the hooks. I may keep the powerdown script, but have it call /etc/rc.d/rc.unRAID stop Something I did yesterday did not shut things down properly. *sigh* I'll create(or add to) /etc/rc.d/rc.local_shutdown appending the cal to /etc/rc.d/rc.unRAID stop. Either way, everything will call the rc.unRAID stop to handle array stopping. Other scripts will handle the actual power off.. We'll just add the proper hooks so the array shutdown is gracefiull. The sed line does work so I've got a powerbutton shutdown now. Good, then use this in the meantime.
August 21, 200817 yr Something I did yesterday did not shut things down properly. *sigh* Don't feel too bad, I had a power failure at my house this past Sunday. The UPS shutdown worked perfectly, except I had it invoke /sbin/poweroff instead of /sbin/powerdown. Needless to say, when power was restored later that morning I was faced with a full parity check. I fixed the script... for the next time a tree on the street behind me decides to grow tall enough to hit the power company primary. Joe L.
August 21, 200817 yr except I had it invoke /sbin/poweroff instead of /sbin/powerdown. This is what I think we may alleviate by putting the logic in /etc/rc.d/rc.unRAID and adding hooks to /etc/rc.d/rc.local_shutdown
August 21, 200817 yr except I had it invoke /sbin/poweroff instead of /sbin/powerdown. This is what I think we may alleviate by putting the logic in /etc/rc.d/rc.unRAID and adding hooks to /etc/rc.d/rc.local_shutdown Exactly.
August 23, 200817 yr Something I did yesterday did not shut things down properly. *sigh* Hey, I did it too, but I know I hit the power button one time before stopping the array lol. Peter
September 7, 200817 yr Is it possible to have one script to do all of the above that can be run with a single line in the go script I will eventually create a package so that installing from pkginstall will handle all of the associated setups. 1. Install powerdown script 2. Update /etc/inittab for ctrl-alt-del support 3. Update kernel.poweroff_cmd for power button control Hi Weebotech, By any change you have a complete package that can do this now? Thanks!
September 7, 200817 yr The more posts I read in this forum, the more addicted I get to this place. I'm not usually the forum type, but you guys are really helpful. Don't know if you guys have a iPhone or other mobile device supporting web browsing and Wi-Fi, but it works great for a clean shut down through safari. Even sent a shortcut of the ip to the desktop of my phone for easy access. Just a thought
September 7, 200817 yr By any change you have a complete package that can do this now? Thanks! I do if you want to beta test it
September 7, 200817 yr By any change you have a complete package that can do this now? Thanks! I do if you want to beta test it I am for it WeeboTech, as I have spare system just for testing - for stuff I don't fully understand yet before implementing to my production server.
September 7, 200817 yr It's attached as powerdown.zip I had to make it as a .zip file to allow posting to the forum. unzip it and a standard slackware install package will be extracted. install with installpkg powerdown-1.01-noarch-unRAID.tgz If you want to hook a powerdown to your control all delete keys (instead of reboot) install with CTRLALTDEL=yes installpkg powerdown-1.01-noarch-unRAID.tgz slack-desc displayed upon install powerdown: powerdown Control scripts for the unRAID server Environment. powerdown: powerdown: Implements powerdown control scripts to assist unRAID environment powerdown: /sbin/powerdown for quick -n- simple powerdown from command line powerdown: powerdown: contrl-alt-del hooks to allow quick keyboard shutdown powerdown: Install with powerdown: powerdown: CTRLALTDEL=yes installpkg powerdown-1.00-noarch-unRAID.tgz powerdown: powerdown: /etc/rc.d/rc.unRAID script to do basic power down functions powerdown: Hooks are placed in /etc/rc.d/rc.local_shutdown powerdown: so that normal poweroff/shutdown commands do a graceful shutdown powerdown: powerdown: Diagnostic mode for dumping and saving syslogs to /boot/logs powerdown: call with /etc/rc.d/rc.unRAID syslog powerdown: Executing install script for powerdown-1.00-noarch-unRAID... This now comes with a new feature called "syslog" This will do a diagnostic dump and save your syslog to the /boot/logs directory. It captures output of smartctl, ifconfig, ethtool It will keep at most 10 syslogs in the logs directory. Each named with date and time. It will also zip the most current syslog into syslog.zip for uploading. This enables us to capture diags on demand or via some predefined schedule. I plan to add a hook to log rotate to call this script. Although I included powerdown script, it is actually scaled down to just call the /etc/rc.d/rc.unRAID script. From my local tests here. The standard reboot/poweroff/shutdown and ctlr-alt-del methods called this script. It worked on my two machines. Standard disclaimers apply. I.E. Before you actually test with a power off... Stop your array manually just for safety sake. LOL. Then watch the console to be sure the script is actually being called. I have a new google projects page at http://code.google.com/p/unraid-powercontrol/
September 8, 200817 yr Nice, I'll have to try this one out and let you know if it works for me. Peter
September 8, 200817 yr Thanks WeeboTech! I planned to install from fresh unraid (using unmodified "go" script); But anyway for some reason my server started with parity check so I have to wait before I can try ur package. Quick Question: Is unmodified unRAID don't have clean shutdown from command line right? Because I think thats what I did crtl+alt+del to reboot my server. Thanks!
September 8, 200817 yr Okay I did install the package using installpkg powerdown-1.00-noarch-unRAID.tgz as I would love to have crt+alt+del to serve me for reboot as my case Centurion 590 dont have reset button. First try: (with server array STOP) Powerbutton activate shutdown mode calling script "level 0" (rc.0 I think) Ctrl+Alt+Del activate reboot mode calling script "level 6" (rc.6 I think) Booted normal as expected! Second try is actual testing with my server array running. Powerbutton activate shutdown mode as before BUT this time when I logged in on web interface my system is doing a Parity check! Hmmmm! dirty shutdown? Anyway I attached syslog captured when I restart my system using web interface. I will resubmit my syslog after parity check. I am using MSI K8N Neo4-F (PCB 1.0) Athlon 64 3500+
September 8, 200817 yr unmodified unRAID don't have clean shutdown from command line right? Yes, that's part of the reason for my script. The current unRAID setup does not do a graceful shutdown if you do not use the browser interface.
September 9, 200817 yr @ WeeboTech Attached is my 2 syslog. Auto-Logs is very nice. rc.unRAID seems works for me (this is what created syslogs right?) Please let me know why I am getting parity check after powerbutton shutdown. Thanks!
Archived
This topic is now archived and is closed to further replies.