From f5651c6eff4dc108586a0a39c38d015e19e3e879 Mon Sep 17 00:00:00 2001 From: Alan Johnston Date: Mon, 4 Jan 2021 19:05:58 +0000 Subject: [PATCH] initial update script --- update.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100755 update.sh diff --git a/update.sh b/update.sh new file mode 100755 index 00000000..113feebc --- /dev/null +++ b/update.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +echo -e "\nupdate script for CubeSatSim\n" + +if [ "$1" = "u" ]; then + + sudo apt-get update && sudo apt-get dist-upgrade -y + + sudo apt-get install -y wiringpi git libasound2-dev i2c-tools cpulimit + +fi + +cd /home/pi/CubeSatSim + +git pull > .updated + +make debug + +FLAG=0 + +if [[ $(grep 'cubesatsim.service' /home/pi/CubeSatSim/.updated) ]]; then + echo "copying cubesatsim.service" + sudo cp systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service + FLAG=1 +else + echo "no changes to cubesatsim.service" +fi + +if [[ $(grep 'rpitx.service' /home/pi/CubeSatSim/.updated) ]]; then + echo "copying rpitx.service" + sudo cp systemd/rpitx.service /etc/systemd/system/rpitx.service + FLAG=1 +else + echo "no changes to rpitx.service" +fi + +if [ $FLAG -eq 1 ]; then + echo "systemctl daemon-reload" + sudo systemctl daemon-reload +else + echo "systemctl restart cubesatsim" + sudo systemctl restart cubesatsim +fi