install script
This commit is contained in:
parent
9f809e2ae1
commit
37f3da620c
74
cleanup_and_isntall.sh
Normal file
74
cleanup_and_isntall.sh
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
#!/bin/bash
|
||||
|
||||
BRANCHE="mqtt"
|
||||
|
||||
show_cron_menu() {
|
||||
echo "Choose option:"
|
||||
echo " 1) Control modem via GPIO"
|
||||
echo " 2) Control modem via MQTT"
|
||||
}
|
||||
|
||||
# force run from root user
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
exec sudo "$0" "$@"
|
||||
fi
|
||||
|
||||
# cleanup old files
|
||||
rm /etc/ppp/chatscripts/sim800c &> /dev/null
|
||||
rm /etc/ppp/peers/sim800c &> /dev/null
|
||||
rm /etc/init.d/sim800c &> /dev/null
|
||||
rm /etc/systemd/system/sim800.service &> /dev/null
|
||||
rm /etc/systemd/system/sim800-healthcheck.service &> /dev/null
|
||||
rm /etc/systemd/system/sim800-healthcheck.timer &> /dev/null
|
||||
systemctl daemon-reload
|
||||
|
||||
rm /etc/ppp/chatscripts/t3hs_sim800 &> /dev/null
|
||||
rm /etc/ppp/peers/t3hs_sim800 &> /dev/null
|
||||
rm /usr/bin/t3hs/t3hs_sim800 &> /dev/null
|
||||
rm /etc/init.d/t3hs_sim800.sh &> /dev/null
|
||||
rm /etc/cron.d/t3hs_sim800_gpio &> /dev/null
|
||||
rm /etc/cron.d/t3hs_sim800_mqtt &> /dev/null
|
||||
echo "Old files removed"
|
||||
|
||||
apt update
|
||||
apt remove -y inetutils-ping
|
||||
apt install -y ppp curl iputils-ping mosquitto_utils
|
||||
echo "Dependencies installed"
|
||||
|
||||
mkdir -p /etc/ppp/chatscripts
|
||||
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/$BRANCH/etc/ppp/chatscripts/t3hs_sim800" > /etc/ppp/chatscripts/t3hs_sim800
|
||||
|
||||
mkdir -p /etc/ppp/peers
|
||||
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/$BRANCH/etc/ppp/peers/t3hs_sim800" > /etc/ppp/peers/t3hs_sim800
|
||||
|
||||
mkdir -p /usr/bin/t3hs
|
||||
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/$BRANCH/usr/bin/t3hs/t3hs_sim800" > /usr/bin/t3hs/t3hs_sim800
|
||||
chmod +x /usr/bin/t3hs/t3hs_sim800
|
||||
|
||||
mkdir -p /etc/init.d
|
||||
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/$BRANCH/etc/init.d/t3hs_sim800.sh" > /etc/init.d/t3hs_sim800.sh
|
||||
chmod +x /etc/init.d/t3hs_sim800.sh
|
||||
|
||||
mkdir -p /etc/cron.d
|
||||
while true; do
|
||||
show_cron_menu
|
||||
read -p "Your choose (1/2): " choice
|
||||
case "$choice" in
|
||||
1)
|
||||
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/$BRANCH/etc/cron.d/t3hs_sim800_gpio" > /etc/cron.d/t3hs_sim800_gpio
|
||||
chmod 644 /etc/cron.d/t3hs_sim800_gpio
|
||||
chown root:root /etc/cron.d/t3hs_sim800_gpio
|
||||
break
|
||||
;;
|
||||
2)
|
||||
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/$BRANCH/etc/cron.d/t3hs_sim800_gpio" > /etc/cron.d/t3hs_sim800_gpio
|
||||
chmod 644 /etc/cron.d/t3hs_sim800_mqtt
|
||||
chown root:root /etc/cron.d/t3hs_sim800_mqtt
|
||||
break
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ ! -f /etc/t3hs/sim800 ]]; then
|
||||
mkdir -p /etc/t3hs
|
||||
curl -sSL "https://git.openergy.ru/LUCKFOX/SIM800C/raw/branch/$BRANCH/etc/t3hs/sim800" > /etc/t3hs/sim800
|
||||
fi
|
||||
Loading…
Reference in New Issue
Block a user