2019-12-15 21:35:51 +01:00
|
|
|
#!/bin/bash
|
|
|
|
######################################################################
|
|
|
|
# Author: Fred (support@qo-op.com)
|
|
|
|
# Version: 0.1
|
|
|
|
# License: AGPL-3.0 (https://choosealicense.com/licenses/agpl-3.0/)
|
2019-11-27 23:43:32 +01:00
|
|
|
# This script modify rc.local to start G1sms+ G1Tag, G1Tx and _CopyLaRadio scripts
|
|
|
|
######################################################################
|
2019-12-15 21:35:51 +01:00
|
|
|
# INJECT it self into /etc/rc.local
|
|
|
|
######################################################################
|
|
|
|
MY_PATH="`dirname \"$0\"`" # relative
|
|
|
|
MY_PATH="`( cd \"$MY_PATH\" && pwd )`" # absolutized and normalized
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
#################### INCEPTION / INSERTION ###########################
|
2019-11-27 23:43:32 +01:00
|
|
|
######################################################################
|
|
|
|
inserted=$(grep -Rw "rc.local.sh" /etc/rc.local)
|
|
|
|
if [[ ! $inserted ]]; then
|
2019-12-15 21:35:51 +01:00
|
|
|
sudo sed -i s/exit\ 0//g /etc/rc.local
|
|
|
|
sudo echo "include $MY_PATH/rc.local.sh" >> /etc/rc.local
|
|
|
|
sudo echo "exit 0" >> /etc/rc.local
|
2019-11-27 23:43:32 +01:00
|
|
|
fi
|
|
|
|
|
2019-12-15 21:35:51 +01:00
|
|
|
######################################################################
|
|
|
|
#### WRITE SYSTEM STARTUP COMMANDS HERE........
|
|
|
|
######################################################################
|
2019-11-27 23:43:32 +01:00
|
|
|
# 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
|
2019-12-15 21:35:51 +01:00
|
|
|
su pi -c "$MY_PATH/_CopyLaRadio/watch.sh &"
|
2019-11-27 23:43:32 +01:00
|
|
|
# LAUNCH COPY SCRIPT
|
2019-12-15 21:35:51 +01:00
|
|
|
su pi -c "$MY_PATH/_CopyLaRadio/copy.sh &"
|
2019-11-27 23:43:32 +01:00
|
|
|
|
|
|
|
# Print the IP address
|
|
|
|
_IP=$(hostname -I | cut -d " " -f 1) || true
|
|
|
|
if [ "$_IP" ]; then
|
|
|
|
printf "IP address is %s\n" "$_IP"
|
2019-12-15 21:35:51 +01:00
|
|
|
$MY_PATH/shell/parle.sh "Adresse IP: $_IP"
|
2019-11-27 23:43:32 +01:00
|
|
|
youtube-dl -U
|
2019-12-15 21:35:51 +01:00
|
|
|
$MY_PATH/shell/parle.sh "Mise à jour de Youtube DL. Terminé!"
|
2019-11-27 23:43:32 +01:00
|
|
|
#IPFS
|
|
|
|
YOU=$(ps aux --sort=+utime | grep ipfs | tail -n 1 | cut -d " " -f 1)
|
|
|
|
if [[ "$YOU" != "" && "$YOU" != "root" ]]; then
|
2019-12-15 21:35:51 +01:00
|
|
|
$MY_PATH/shell/parle.sh "IPFS OK. Système de fichier interplanétaire activé."
|
2019-11-27 23:43:32 +01:00
|
|
|
fi
|
|
|
|
else
|
2019-12-15 21:35:51 +01:00
|
|
|
$MY_PATH/shell/parle.sh "Connexion Internet Impossible!"
|
2019-11-27 23:43:32 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# LANCEMENT G1Tag READ
|
|
|
|
if [[ -e "/dev/ttyACM0" ]]; then
|
2019-12-15 21:35:51 +01:00
|
|
|
cd $MY_PATH && ./shell/tag_READ.sh &
|
|
|
|
$MY_PATH/shell/parle.sh "Lecteur G1 tag"
|
2019-11-27 23:43:32 +01:00
|
|
|
fi
|
|
|
|
|
2019-12-15 21:35:51 +01:00
|
|
|
if [[ -d "$MY_PATH/www/rompr" ]]; then
|
|
|
|
$MY_PATH/shell/parle.sh "Jukebox interplanétaire accessible"
|
2019-11-27 23:43:32 +01:00
|
|
|
fi
|
|
|
|
|