You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
444 lines
11 KiB
444 lines
11 KiB
#!/bin/bash
|
|
|
|
echo -e "\nupdate script for CubeSatSim v2.1\n"
|
|
|
|
if [ "$1" = "n" ] ; then
|
|
# if [ -z "$2" ] ; then
|
|
noreboot=1
|
|
else
|
|
noreboot=0
|
|
fi
|
|
|
|
# echo "No reboot"
|
|
# echo $noreboot
|
|
|
|
sudo rm /home/pi/CubeSatSim/morse.wav /home/pi/CubeSatSim/id.txt /home/pi/CubeSatSim/cw.txt > /dev/null 2>&1
|
|
|
|
if [ "$1" = "u" ]; then
|
|
|
|
# sudo apt-get update && sudo apt-get dist-upgrade -y
|
|
sudo apt-get update -y
|
|
|
|
sudo apt-get install -y git libasound2-dev i2c-tools build-essential libgd-dev libmagic-dev python3-pip minicom
|
|
|
|
fi
|
|
|
|
sudo apt-get install -y python3-smbus
|
|
|
|
sudo sed -i 's/update.sh/update /g' /etc/motd
|
|
|
|
sudo sed -i 's/installed and/installed\nand/g' /etc/motd
|
|
|
|
sudo sed -i 's/more information/more\ninformation/g' /etc/motd
|
|
|
|
sudo sed -i 's/update to/update\nto/g' /etc/motd
|
|
|
|
#sudo sed -i 's/console=tty1 r/console=tty1 maxcpus=1 r/g' /boot/cmdline.txt # single core if Pi Zero 2
|
|
sudo sed -i 's/console=tty1 maxcpus=1 r/console=tty1 r/g' /boot/cmdline.txt # remove single core
|
|
|
|
cd /home/pi/CubeSatSim
|
|
|
|
git pull --no-rebase > .updated
|
|
|
|
make debug
|
|
|
|
FILE=/home/pi/CubeSatSim/command_tx
|
|
if [ -f "$FILE" ]; then
|
|
echo "$FILE exists."
|
|
else
|
|
echo "creating $FILE"
|
|
echo "True\n" > /home/pi/CubeSatSim/command_tx
|
|
fi
|
|
|
|
FILE=/home/pi/CubeSatSim/command_count.txt
|
|
if [ -f "$FILE" ]; then
|
|
echo "$FILE exists."
|
|
else
|
|
echo "creating $FILE"
|
|
echo "0\n" > /home/pi/CubeSatSim/command_count.txt
|
|
fi
|
|
|
|
FLAG=0
|
|
|
|
if [[ $(diff systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service) ]]; then
|
|
echo "changed cubesatsim.service."
|
|
sudo cp /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service
|
|
FLAG=1
|
|
else
|
|
echo "no changes to cubesatsim.service."
|
|
fi
|
|
|
|
FILE=/etc/systemd/system/rpitx.service
|
|
if [ -f "$FILE" ]; then
|
|
sudo systemctl disable rpitx
|
|
sudo rm /etc/systemd/system/rpitx.service
|
|
fi
|
|
|
|
FILE=/etc/systemd/system/transmit.service
|
|
if [ -f "$FILE" ]; then
|
|
if [[ $(diff systemd/transmit.service /etc/systemd/system/transmit.service) ]]; then
|
|
echo "changed transmit.service."
|
|
sudo cp /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service
|
|
FLAG=1
|
|
else
|
|
echo "no change to transmit.service."
|
|
fi
|
|
else
|
|
echo "creating transmit.service."
|
|
sudo cp /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service
|
|
FLAG=1
|
|
fi
|
|
|
|
FILE=/etc/systemd/system/command.service
|
|
if [ -f "$FILE" ]; then
|
|
if [[ $(diff systemd/command.service /etc/systemd/system/command.service) ]]; then
|
|
echo "changed command.service."
|
|
sudo cp /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service
|
|
FLAG=1
|
|
else
|
|
echo "no change to command.service."
|
|
fi
|
|
else
|
|
echo "creating command.service."
|
|
sudo cp /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service
|
|
sudo systemctl enable command
|
|
FLAG=1
|
|
fi
|
|
|
|
FILE=/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg
|
|
if [ ! -f "$FILE" ]; then
|
|
echo "Copying SSTV image 1."
|
|
cp /home/pi/CubeSatSim/sstv/sstv_image_1_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg
|
|
fi
|
|
|
|
FILE=/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg
|
|
if [ ! -f "$FILE" ]; then
|
|
echo "Copying SSTV image 2."
|
|
cp /home/pi/CubeSatSim/sstv/sstv_image_2_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg
|
|
fi
|
|
|
|
grep 'update' /home/pi/CubeSatSim/.updated
|
|
if [[ $(grep 'update' /home/pi/CubeSatSim/.updated) ]]; then
|
|
echo "update script updated, running again"
|
|
/home/pi/CubeSatSim/update
|
|
fi
|
|
|
|
if [ ! -d "/home/pi/PiSSTVpp" ]; then
|
|
|
|
# sudo apt-get update && sudo apt-get dist-upgrade -y
|
|
sudo apt-get update -y
|
|
|
|
sudo apt-get install -y python-picamera python3-picamera build-essential libgd-dev libmagic-dev
|
|
|
|
|
|
cd
|
|
|
|
git clone https://github.com/alanbjohnston/PiSSTVpp.git
|
|
|
|
cd PiSSTVpp
|
|
|
|
make pisstvpp
|
|
|
|
cd
|
|
|
|
|
|
sudo raspi-config nonint do_camera 0
|
|
|
|
|
|
FILE=/home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg
|
|
if [ ! -f "$FILE" ]; then
|
|
echo "Copying SSTV image 1."
|
|
cp /home/pi/CubeSatSim/sstv/sstv_image_1_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_1_320_x_256.jpg
|
|
fi
|
|
|
|
FILE=/home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg
|
|
if [ ! -f "$FILE" ]; then
|
|
echo "Copying SSTV image 2."
|
|
cp /home/pi/CubeSatSim/sstv/sstv_image_2_320_x_256.jpg /home/pi/CubeSatSim/sstv_image_2_320_x_256.jpg
|
|
fi
|
|
|
|
# echo "You need to reboot to complete this update. Reboot now (y/n)?"
|
|
|
|
# read -r ANS
|
|
|
|
# if [ "$ANS" = "y" ]; then
|
|
|
|
# sudo reboot now
|
|
|
|
# else
|
|
|
|
# echo "The CubeSatSim software may not work correctly until you reboot."
|
|
|
|
# fi
|
|
|
|
fi
|
|
|
|
if [ ! -d "/home/pi/rpitx" ]; then
|
|
|
|
cd
|
|
git clone https://github.com/alanbjohnston/rpitx.git
|
|
cd rpitx
|
|
./install.sh
|
|
cd
|
|
else
|
|
|
|
if [[ $(grep 'SYNCWITHPWM' /home/pi/rpitx/src/librpitx/src/fskburst.h) ]]; then
|
|
echo "rpitx library already updated"
|
|
else
|
|
echo "updating rpitx"
|
|
cd /home/pi/rpitx
|
|
git pull
|
|
./update.sh
|
|
cd
|
|
fi
|
|
fi
|
|
|
|
if [ ! -d "/home/pi/WiringPi" ]; then
|
|
|
|
cd
|
|
|
|
git clone https://github.com/PinkFreud/WiringPi
|
|
cd WiringPi
|
|
./build debian
|
|
|
|
sudo dpkg -i debian-template/wiringpi-2.61-1.deb
|
|
|
|
cd
|
|
|
|
cd CubeSatSim
|
|
make debug
|
|
|
|
FLAG=1
|
|
|
|
cd
|
|
|
|
fi
|
|
|
|
cd /home/pi/pi-power-button
|
|
|
|
git checkout master
|
|
|
|
|
|
git pull --no-rebase > .updated_p
|
|
|
|
grep 'changed' /home/pi/pi-power-button/.updated_p
|
|
if [[ $(grep 'changed' /home/pi/pi-power-button/.updated_p) ]]; then
|
|
|
|
echo "updating pi-power-button."
|
|
|
|
script/install
|
|
|
|
FLAG=1
|
|
|
|
|
|
else
|
|
echo "nothing to do for pi-power-button."
|
|
fi
|
|
|
|
if [[ $(grep 'dtparam=audio=on' /boot/config.txt) ]]; then
|
|
echo "dtparam=audio=on already in /boot/config.txt"
|
|
else
|
|
echo "adding dtparam=audio=on to /boot/config.txt"
|
|
sudo sh -c 'echo "\ndtparam=audio=on" >> /boot/config.txt'
|
|
FLAG=1
|
|
fi
|
|
|
|
if [[ $(grep 'dtoverlay=audremap,enable_jack=on' /boot/config.txt) ]]; then
|
|
echo "dtoverlay=audremap,enable_jack=on already in /boot/config.txt"
|
|
else
|
|
echo "adding dtoverlay=audremap,enable_jack=on to /boot/config.txt"
|
|
sudo sh -c 'echo "\ndtoverlay=audremap,enable_jack=on" >> /boot/config.txt'
|
|
FLAG=1
|
|
fi
|
|
|
|
if [[ $(grep 'dtoverlay=pwm,pin=18,func=2' /boot/config.txt) ]]; then
|
|
echo "dtoverlay=pwm,pin=18,func=2 already in /boot/config.txt"
|
|
else
|
|
echo "adding dtoverlay=pwm,pin=18,func=2 to /boot/config.txt"
|
|
sudo sh -c 'echo "\ndtoverlay=pwm,pin=18,func=2" >> /boot/config.txt'
|
|
FLAG=1
|
|
|
|
cd /home/pi/pi-power-button
|
|
git pull --no-rebase
|
|
git checkout reboot-mode-change
|
|
script/install
|
|
|
|
# sudo apt-get update && sudo apt-get dist-upgrade -y
|
|
sudo apt-get update -y
|
|
sudo apt-get install -y libjpeg-dev zlib1g-dev libfreetype6-dev liblcms1-dev libopenjp2-7 libtiff5 python3-pil
|
|
sudo pip3 install adafruit-blinka RPI.GPIO adafruit-extended-bus adafruit-circuitpython-ina219 pillow
|
|
|
|
fi
|
|
|
|
if [[ $(grep 'disable_splash=1' /boot/config.txt) ]]; then
|
|
echo "disable_splash=1 already in /boot/config.txt"
|
|
else
|
|
echo "adding to /boot/config.txt"
|
|
sudo sh -c 'echo "\ndisable_splash=1" >> /boot/config.txt'
|
|
FLAG=1
|
|
fi
|
|
|
|
if [[ $(grep 'boot_delay=0' /boot/config.txt) ]]; then
|
|
echo "boot_delay=0 already in /boot/config.txt"
|
|
else
|
|
echo "adding to /boot/config.txt"
|
|
sudo sh -c 'echo "\nboot_delay=0" >> /boot/config.txt'
|
|
FLAG=1
|
|
fi
|
|
|
|
if ! grep -q force_turbo=1 /boot/config.txt ; then
|
|
sudo sh -c 'echo "force_turbo=1" >> /boot/config.txt'
|
|
FLAG=1
|
|
fi
|
|
|
|
#if [ ! -f "/home/pi/CubeSatSim/telem_string.txt" ]; then
|
|
|
|
# sudo apt-get update && sudo apt-get dist-upgrade -y
|
|
|
|
# sudo apt-get install -y libjpeg-dev zlib1g-dev libfreetype6-dev liblcms1-dev libopenjp2-7 libtiff5 -y
|
|
|
|
# sudo pip3 install pillow
|
|
|
|
#fi
|
|
|
|
if [ ! -d "/home/pi/pi_pacsat" ]; then
|
|
|
|
FLAG=1
|
|
|
|
cd
|
|
|
|
git clone https://github.com/ac2cz/iors_common.git
|
|
|
|
cd iors_common/Debug/
|
|
|
|
make all
|
|
|
|
sudo ./install.sh
|
|
|
|
cd
|
|
|
|
git clone https://github.com/ac2cz/pi_pacsat.git
|
|
|
|
cd pi_pacsat/Debug
|
|
|
|
make all
|
|
|
|
mkdir /home/pi/PacSat
|
|
mkdir /home/pi/PacSat/pacsat
|
|
mkdir /home/pi/PacSat/pacsat/dir
|
|
|
|
export LD_LIBRARY_PATH=/mnt/usb-disk/ariss/lib:/usr/local/lib/iors_common:$LD_LIBRARY_PATH
|
|
|
|
value=`cat /home/pi/CubeSatSim/sim.cfg`
|
|
echo "$value" > /dev/null
|
|
set -- $value
|
|
|
|
echo "bit_rate=9600" > pacsat.config
|
|
echo "bbs_callsign=$1" >> pacsat.config
|
|
echo "broadcast_callsign=$1-11" >> pacsat.config
|
|
echo "digi_callsign=$1-1" >> pacsat.config
|
|
echo "max_frames_in_tx_buffer=5" >> pacsat.config
|
|
|
|
echo "pb_open=1" > pacsat.state
|
|
echo "uplink_open=1" >> pacsat.state
|
|
|
|
sudo sed -i 's/#hdmi_group=1/hdmi_group=2/g' /boot/config.txt
|
|
sudo sed -i 's/#hdmi_mode=1/hdmi_mode=16/g' /boot/config.txt
|
|
sudo sed -i 's/#hdmi_force_hotplug=1/hdmi_force_hotplug=1/g' /boot/config.txt
|
|
|
|
sudo raspi-config nonint do_vnc 0
|
|
|
|
cd /tmp
|
|
|
|
wget https://www.g0kla.com/pacsat/downloads/test/PacSatGround_0.46m_linux.tar.gz
|
|
|
|
tar -xzf PacSatGround_0.46m_linux.tar.gz -C /home/pi/Desktop
|
|
|
|
rm PacSatGround_0.46m_linux.tar.gz
|
|
|
|
cp /home/pi/CubeSatSim/spacecraft/PacSatGround_0.46m/* /home/pi/Desktop/PacSatGround_0.46m_linux/spacecraft/
|
|
|
|
mkdir /home/pi/PacSatGround
|
|
|
|
sudo usermod -a -G gpio pi
|
|
|
|
sudo apt-get install default-jdk -y
|
|
|
|
cd
|
|
|
|
fi
|
|
|
|
cd /home/pi/direwolf
|
|
|
|
#git status
|
|
|
|
#git status | grep 'invert'
|
|
|
|
if [[ ! $(git status | grep 'invert') ]]; then
|
|
|
|
echo "updating direwolf to ptt invert version"
|
|
|
|
git pull --no-rebase
|
|
git checkout invert
|
|
make clean
|
|
make -j
|
|
sudo make install
|
|
make install-rpi
|
|
cd
|
|
|
|
fi
|
|
|
|
changed=0
|
|
value=`cat /home/pi/CubeSatSim/sim.cfg`
|
|
# echo "$value"
|
|
echo "$value" > /dev/null
|
|
set -- $value
|
|
|
|
if [ -z "$1" ] ; then n1="AMSAT" ; changed=1 ; else n1=$1 ; fi # callsign
|
|
if [ -z "$2" ] ; then n2="0" ; changed=1 ; else n2=$2 ; fi # reset count
|
|
if [ -z "$3" ] ; then n3="0" ; changed=1 ; else n3=$3 ; fi # lat
|
|
if [ -z "$4" ] ; then n4="0" ; changed=1 ; else n4=$4 ; fi # lon
|
|
if [ -z "$5" ] ; then n5="no" ; changed=1 ; else n5=$5 ; fi # sim mode
|
|
if [ -z "$6" ] ; then n6="3" ; changed=1 ; else n6=$6 ; fi # squelch
|
|
if [ -z "$7" ] ; then n7="434.9000" ; changed=1 ; else n7=$7 ; fi # transmit frequency
|
|
if [ -z "$8" ] ; then n8="435.0000" ; changed=1 ; else n8=$8 ; fi # receive frequency
|
|
if [ -z "$9" ] ; then n9="no" ; changed=1 ; else n9=$9 ; fi # hab mode
|
|
if [ -z "${10}" ] ; then m1="0" ; changed=1 ; else m1=${10} ; fi # rx pl code
|
|
if [ -z "${11}" ] ; then m2="0" ; changed=1 ; else m2=${11} ; fi # tx pl code
|
|
|
|
if [ $changed -eq 1 ]; then
|
|
echo -e "Current sim.cfg configuration file:"
|
|
echo
|
|
echo $1 $2 $3 $4 $5 $6 $7 $8 $9 ${10} ${11}
|
|
echo -e "\nCubeSatSim configuration sim.cfg file updated to: \n"
|
|
echo
|
|
echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $m1 $m2
|
|
echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $m1 $m2 > /home/pi/CubeSatSim/sim.cfg
|
|
echo
|
|
fi
|
|
|
|
if [ "$noreboot" = "0" ] ; then
|
|
|
|
if [ $FLAG -eq 1 ]; then
|
|
echo "systemctl daemon-reload and reboot"
|
|
sudo systemctl daemon-reload
|
|
sudo reboot -h now
|
|
# sudo cubesatsim
|
|
else
|
|
grep 'changed' /home/pi/CubeSatSim/.updated
|
|
if [[ $(grep 'changed' /home/pi/CubeSatSim/.updated) ]]; then
|
|
echo "reboot due to code changes " | wall
|
|
sudo reboot -h now
|
|
# sudo cubesatsim
|
|
else
|
|
echo "nothing to do."
|
|
fi
|
|
fi
|
|
else
|
|
if [ $FLAG -eq 1 ]; then
|
|
echo "reboot needed for changes to take effect"
|
|
fi
|
|
fi
|
|
|
|
echo "CubeSatSim update complete."
|