Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
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.
That will start it in the background, if it doesn't already, and the nohup frees it up from the parent process, which is the ssh console. Otherwise, when the console exits, mpg123 may also exit. Add at least a sleep 3 such as
nohup mpg123 -repeat &
sleep 3
exit
That gives mpg123 time to fully spawn before the console exits.
here are the scripts, remember, security is not paramount: This runs on the server
Code:
#!/bin/bash
#Archives old MP3's, and compresses new ones
#Set DATE variable to today
DATE=`date +'%m-%d-%Y'`
#Checks to see if there is a new wav file. Does nothing if there is not.
if ls /audio/ | grep -q wav &> /dev/null
then
#Copy old MP3's into an archive directory, then deletes
mv /audio/*.mp3 /audio/archive
#Encodes wav file into MP3
lame -a -h -S -p -b 96 /audio/*.wav /audio/$DATE.mp3&&rm /audio/*.wav
#Changes file permissions
chown root:root /audio/$DATE.mp3
#Forces clients to transfer new files
ssh -qi /root/.ssh/id_rsa -l root 10.85.16.222 "/root/update_audio"
ssh -qi /root/.ssh/id_rsa -l root 10.85.16.223 "/root/update_audio"
fi
exit
This runs on the clients (this is /root/update_audio):
Code:
#!/bin/bash
#Updates file currently playing
#Kills player
killall mpg123
#Moves old MP3's to a temporary location
mv /audio/*.mp3 /tmp/
#Copies new MP3's to /audio
if scp -i /root/.ssh/id_rsa root@10.85.16.221:/audio/*.mp3 /audio/ > /dev/null
then
#Remove old MP3's
rm /tmp/*.mp3
#Sets permissions
chmod 644 /audio/*.mp3
else
#Move old MP3's back into original location upon failure
mv /tmp/*.mp3 /audio/
fi
#Repeats new announcement forever
nohup mpg123 --random /audio/*.mp3&
sleep 3
exit
well, audio_script runs on radioserver (a file repository where people dump wavs) It runs a 3pm every day. It then sshs into the other two machines and runs the scripts. It works great.
Unfortunately, I end up with a ton of ssh processes after a while.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.