move venv to start of script

Added support for Bullseye OS and updated installation steps for Python virtual environment and dependencies.
master-b-gpio
Alan Johnston 1 month ago committed by GitHub
parent af9afad6ac
commit 666c4af6e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -2,6 +2,7 @@
FLAG=0 FLAG=0
checkout=0 checkout=0
BULLSEYE=0
FILE=/home/pi/CubeSatSim/cubesatsim # code has already been compiled FILE=/home/pi/CubeSatSim/cubesatsim # code has already been compiled
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
@ -133,6 +134,7 @@ if [[ $(grep '11.' /etc/debian_version) ]]; then
fi fi
if [[ $(grep 'bookworm' /etc/os-release) ]]; then if [[ $(grep 'bookworm' /etc/os-release) ]]; then
BULLSEYE=1
echo "Bookworm detected, installation continuing." echo "Bookworm detected, installation continuing."
sudo cp /boot/firmware/config.txt /boot/firmware/config.txt.0 sudo cp /boot/firmware/config.txt /boot/firmware/config.txt.0
@ -251,6 +253,20 @@ elif [[ $(grep 'trixie' /etc/os-release) ]]; then
fi fi
fi fi
if [ ! -d "/home/pi/venv" ]; then
cd
sudo apt install -y python3-venv
sudo python3 -m venv venv
source /home/pi/venv/bin/activate
curl https://bootstrap.pypa.io/get-pip.py | sudo /home/pi/venv/bin/python3
sudo /home/pi/venv/bin/pip3 install adafruit_extended_bus
sudo /home/pi/venv/bin/pip3 install adafruit-circuitpython-ina219
fi
FILE=/home/pi/CubeSatSim/sim.cfg FILE=/home/pi/CubeSatSim/sim.cfg
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
echo "$FILE exists." echo "$FILE exists."
@ -272,8 +288,8 @@ if [ -f "$FILE" ]; then
if [ -z "$9" ] ; then n9="no" ; changed=1 ; else n9=$9 ; fi # hab mode 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 "${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 [ -z "${11}" ] ; then m2="0" ; changed=1 ; else m2=${11} ; fi # tx pl code
if [ -z "${12}" ] ; then m1="no" ; changed=1 ; else m1=${12} ; fi # random fail if [ -z "${12}" ] ; then m3="no" ; changed=1 ; else m3=${12} ; fi # random fail
if [ -z "${13}" ] ; then m2="60" ; changed=1 ; else m2=${13} ; fi # random fail period if [ -z "${13}" ] ; then m4="60" ; changed=1 ; else m4=${13} ; fi # random fail period
if [ $changed -eq 1 ]; then if [ $changed -eq 1 ]; then
echo -e "Current sim.cfg configuration file:" echo -e "Current sim.cfg configuration file:"
@ -338,20 +354,18 @@ fi
sudo systemctl disable gpsd.socket sudo systemctl disable gpsd.socket
if [ ! -d "/home/pi/WiringPi" ]; then if [ ! -d "/home/pi/WiringPi" ]; then
cd cd
git clone https://github.com/alanbjohnston/WiringPi git clone https://github.com/alanbjohnston/WiringPi
cd WiringPi cd WiringPi
./build debian ./build debian
sudo dpkg -i debian-template/wiringpi-2.61-1.deb sudo dpkg -i debian-template/wiringpi-2.61-1.deb
fi fi
cd cd
#changed to python3-smbus if [ ! $BULLSEYE -eq 1 ]; then
sudo apt install -y libtiff6
sudo apt install -y libtiff6 fi
sudo apt install -y python3-pip python3-smbus libjpeg-dev zlib1g-dev libfreetype6-dev libopenjp2-7 python3-pil python3-serial libusb-1.0-0 libusb-1.0-0-dev sudo apt install -y python3-pip python3-smbus libjpeg-dev zlib1g-dev libfreetype6-dev libopenjp2-7 python3-pil python3-serial libusb-1.0-0 libusb-1.0-0-dev
@ -437,7 +451,7 @@ else
fi fi
fi fi
if [[ $(diff systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service) ]]; then if [[ $(diff /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service) ]]; then
echo "changed cubesatsim.service." echo "changed cubesatsim.service."
sudo cp /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service sudo cp /home/pi/CubeSatSim/systemd/cubesatsim.service /etc/systemd/system/cubesatsim.service
FLAG=1 FLAG=1
@ -453,7 +467,7 @@ fi
FILE=/etc/systemd/system/transmit.service FILE=/etc/systemd/system/transmit.service
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
if [[ $(diff systemd/transmit.service /etc/systemd/system/transmit.service) ]]; then if [[ $(diff /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service) ]]; then
echo "changed transmit.service." echo "changed transmit.service."
sudo cp /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service sudo cp /home/pi/CubeSatSim/systemd/transmit.service /etc/systemd/system/transmit.service
FLAG=1 FLAG=1
@ -468,7 +482,7 @@ fi
FILE=/etc/systemd/system/command.service FILE=/etc/systemd/system/command.service
if [ -f "$FILE" ]; then if [ -f "$FILE" ]; then
if [[ $(diff systemd/command.service /etc/systemd/system/command.service) ]]; then if [[ $(diff /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service) ]]; then
echo "changed command.service." echo "changed command.service."
sudo cp /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service sudo cp /home/pi/CubeSatSim/systemd/command.service /etc/systemd/system/command.service
FLAG=1 FLAG=1
@ -513,34 +527,6 @@ sudo sed -i 's/DEVICES=""/DEVICES="\/dev\/serial0"/g' /etc/default/gpsd
sudo sed -i 's/GPSD_OPTIONS=""/GPSD_OPTIONS="-s 9600"/g' /etc/default/gpsd sudo sed -i 's/GPSD_OPTIONS=""/GPSD_OPTIONS="-s 9600"/g' /etc/default/gpsd
changed=0
value=`cat /home/pi/CubeSatSim/sim.cfg`
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 n10="0" ; changed=1 ; else n10=${10} ; fi # rx pl code
if [ -z "${11}" ] ; then n11="0" ; changed=1 ; else n11=${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 $n10 $n11
echo $n1 $n2 $n3 $n4 $n5 $n6 $n7 $n8 $n9 $n10 $n11 > /home/pi/CubeSatSim/sim.cfg
echo
fi
if [ ! -d "/home/pi/fctelem" ]; then if [ ! -d "/home/pi/fctelem" ]; then
echo "Installing fctelem binary v0.2 for FUNcube mode" echo "Installing fctelem binary v0.2 for FUNcube mode"
cd cd
@ -618,21 +604,6 @@ if [ ! -f "/home/pi/fcdctl/fcdctl" ]; then
make fcdpp make fcdpp
fi fi
if [ ! -d "/home/pi/venv" ]; then
cd
sudo apt install python3-venv
sudo python3 -m venv venv
source /home/pi/venv/bin/activate
curl https://bootstrap.pypa.io/get-pip.py | sudo /home/pi/venv/bin/python3
sudo /home/pi/venv/bin/pip3 install adafruit_extended_bus
sudo /home/pi/venv/bin/pip3 install adafruit-circuitpython-ina219
fi
cd cd
#echo "Would you like to reboot to complete the installation (y/n)?" #echo "Would you like to reboot to complete the installation (y/n)?"

Loading…
Cancel
Save

Powered by TurnKey Linux.