Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a samba share called "shutdown". I want to write a script that is run when that share is logged into that will shutdown my server. I regularly view movies using my xbox and don't want to have to walk into my living room to shutdown my server. (RPC stuff from client is not an option)
sys specs:
Debian Squeeze
samba 3.5.6
No matter what bash script I write, I can't get it done. Can someone help me?
Why don't you use ssh to shutdown server. It is quite easy.
Because there are no good SSH clients for the Xbox.
@Hailey's_Comet: You don't even need a separate share for this. Copy a small mp3 file to your normal share and call it shutdown.mp3, so that you can open it with the Xbox. Now you can use inotify to wait for that file to be opened by you and use that event to shutdown the system.
Why don't you use ssh to shutdown server. It is quite easy.
Because I am trying to get this done with the ability to use ANYTHING that can access a simple samba share. I am currently writing this from a laptop logged into my server with XDMCP tunneled in SSH, which is beyond mere SSH. I have a myriad of means already, I just want one more.
Besides, if I can get it done it will be the end to a long project.
Because there are no good SSH clients for the Xbox.
@Hailey's_Comet: You don't even need a separate share for this. Copy a small mp3 file to your normal share and call it shutdown.mp3, so that you can open it with the Xbox. Now you can use inotify to wait for that file to be opened by you and use that event to shutdown the system.
To make it end-user configurable for multiple monitoring, I will be making a script that will be callable with args from init scripts, but for now this is what I am using (unconfigured state):
Code:
#!/bin/bash
monitor="/path/to/shared/dir"
logfile="/var/log/samba/smbshutdown.log"
success="Recieved shutdown command via samba"
failure="An error occurred with smbshutdown->inotifywait"
cmd="/sbin/poweroff &"
inotifywait -e access "$monitor"
if (( $? > 0 )) then
_date=`date`
echo "$failure @ $_date" >> "$logfile"
exit 1
else
_date=`date`
echo "$success @ $_date" >> "$logfile"
$cmd
fi
exit 0
When I am done, I will post it to bashscripts.org so I don't lose it!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.