G1sms/rc.local.sh

61 lines
1.8 KiB
Bash
Executable File

#!/bin/sh
#
# This script modify rc.local to start G1sms+ G1Tag, G1Tx and _CopyLaRadio scripts
######################################################################
# INJECT it self
######################################################################
inserted=$(grep -Rw "rc.local.sh" /etc/rc.local)
if [[ ! $inserted ]]; then
sed -i s/exit\ 0//g /etc/rc.local
echo "include /home/pi/G1sms+/rc.local.sh" >> /etc/rc.local
echo "exit 0" >> /etc/rc.local
fi
######################################################################
# mpd Runs like pi and some rights are bad!!
chown -R pi /var/run/mpd
chown -R pi /run/mpd
# RESET LOG
echo "" > /var/log/mpd/mpd.log
# CREATE EXCHANGE FILEs for pi & www-data
touch /tmp/ytdl.list
chmod 664 /tmp/ytdl.list
chown pi:www-data /tmp/ytdl.list
touch /tmp/youtube-dl.log
chmod 664 /tmp/youtube-dl.log
chown pi:www-data /tmp/youtube-dl.log
# LAUNCH BUTTONS WATCH
su pi -c "/home/pi/G1sms+/_CopyLaRadio/watch.sh &"
# LAUNCH COPY SCRIPT
su pi -c "/home/pi/G1sms+/_CopyLaRadio/copy.sh &"
# Print the IP address
_IP=$(hostname -I | cut -d " " -f 1) || true
if [ "$_IP" ]; then
printf "IP address is %s\n" "$_IP"
/home/pi/G1sms+/shell/parle.sh "Adresse IP: $_IP"
youtube-dl -U
/home/pi/G1sms+/shell/parle.sh "Mise à jour de Youtube DL. Terminé!"
#IPFS
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
if [[ "$YOU" != "" && "$YOU" != "root" ]]; then
/home/pi/G1sms+/shell/parle.sh "IPFS OK. Système de fichier interplanétaire activé."
fi
else
/home/pi/G1sms+/shell/parle.sh "Connexion Internet Impossible!"
fi
# LANCEMENT G1Tag READ
if [[ -e "/dev/ttyACM0" ]]; then
cd /home/pi/G1sms+ && ./shell/tag_READ.sh &
/home/pi/G1sms+/shell/parle.sh "Lecteur G1 tag"
fi
if [[ -d "/home/pi/G1sms+/www/rompr" ]]; then
/home/pi/G1sms+/shell/parle.sh "Jukebox interplanétaire accessible"
fi