Yes, it is just a text file. You would just copy/paste the bash script I mentioned into a text file. You don't want it to have a file extension though. The easiest way would be to copy the lines above for the bash script and then open Terminal and type the following commands:
cd /usr/local
vi myshutdown
(I don't recall if vi starts off in editing mode but you may need to type an i first to get into insert mode. So, just type the i now and if you see an i appear just use the <delete> key to remove it. You should see the word INSERT appear on the screen)
<Command>V (to paste into vi)
<esc>
:w
:q
Line by line:
Change Directory (cd) into /usr/local
Open Unix application vi and create a file in the current directory with the name myshutdown
(i if not in insert mode)
paste the clipboard (The five lines you copied earlier)
Escape out of editing mode
Write the file contents to disk (:w)
Quit out of vi (:q)
To activate it you would either put it into the crontab file mentioned earlier (The whole path - /usr/local/myshutdown) or use PHP to invoke it with a system or exec call
You modified both sudoers files so you would need to type sudo
shutdown -h now to have that take effect. You would also probably need to restart for the modified sudoers file to take effect.
Also, the line is wrong (
%users ALL=NOPASSWD: /sbin/shutdown -h now). It should be %users ALL=NOPASSWD: /sbin/shutdown .
And, you need to make sure the user you are using is in the users group (That is what you are saying by using %users). To check just type groups at the command prompt. This will show the groups the current user is in. For PHP to run this command you need to check which user it is run as. Most likely it will be apache or www. Either add the user to the users group or add another line to the sudoers file for that group. To find out what user/group PHP is running under create a file named phpinfo.php and
Here are a couple of links that will help you:
Sample sudoers file -
http://www.gratisoft.us/sudo/sample.sudoersgroups command -
http://www.howtogeek.com/howto/ubuntu/see-which-groups-your-linux-user-belongs-to/I hope this helps. I may not have explained things well.