-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·28 lines (22 loc) · 912 Bytes
/
setup.sh
File metadata and controls
executable file
·28 lines (22 loc) · 912 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
if [ "$(id -u)" -ne 0 ] ; then
echo "This script must be executed with root privileges."
exit 1
fi
[ $SUDO_USER ] && U=$SUDO_USER || U=`who | awk '{print $1}' | head -1`
echo "Setting up crons for user $U"
# Make mp3 directory
mkdir -p /srv/mp3
chmod 777 /srv/mp3 # We'll be regularly writing to this dir.
# Copy scripts to /opt
REPO="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "Copying over executables to /opt/"
cp -a $REPO /opt/
chmod +x /opt/setup-disk-radio/*sh
# Add scripts to crontab
echo "1 5 * * * $U python2 /opt/setup-disk-radio/musicscope.py" >> /etc/crontab
echo "1 17 * * * $U /opt/setup-disk-radio/clearoldsongs.sh" >> /etc/crontab
echo "@reboot $U /opt/setup-disk-radio/radio-player.sh" >> /etc/crontab
# First run to get some songs
sudo -u $U python2 /opt/setup-disk-radio/musicscope.py
sudo -u $U /opt/setup-disk-radio/radio-player.sh