Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Startup Script #40

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion OnLand/ControlLaptop/SocketController.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import socket
import logging as log
from ControlLaptop import Paradigm_pb2
import Paradigm_pb2
from ControlLaptop.LocalStorage.ConfigurationSotrage import DEFAULT_CONFIGURATION
from config import POD_IP, POD_CONFIG_PORT

Expand Down
2 changes: 1 addition & 1 deletion OnLand/ControlLaptop/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from ControlLaptop.LocalStorage.ConfigurationSotrage import LocalStorage
from ControlLaptop.LocalStorage.FlightConfig import FlightConfig
from ControlLaptop.SocketController import PodCommunicator
from templates._sidebar import get_page_title, NAV_BAR
from ControlLaptop.templates._sidebar import get_page_title, NAV_BAR
from ControlLaptop.forms import FlightConfigurationForm
import collections

Expand Down
104 changes: 104 additions & 0 deletions paradigm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
#!/bin/bash

:'
Requirments:
git
sudo apt-get install git
python3
sudo apt-get install python3
pip
sudo apt install python-pip
virtualenv
sudo apt-get install python-virtualenv
Protobuf
https://github.com/protocolbuffers/protobuf/releases/tag/v3.8.0
extract and enter folder
./configure
make
make check
sudo make install
sudo ldconfig

You will also likely have to:
chmod u+x paradigm.sh

Search for your systems list of "startup applications" and add this script to it
'

# Get sudo privileges
sudo -s
# Dependencies to check
dependencies=(git python3 python-pip python-virtualenv wget unzip)

# Install missing dependencies
install_dependency () {
sudo -s
apt-get install $@
}

# Check for dependencies
for i in "${dependencies[@]}";
to_install=()
do version="$('$i' --version)" &> /dev/null
if [ [ $version =~ 'command not found' ]];
echo "Package is NOT installed! Attempting to install it"
to_install+=("$i")
else
echo "Package is installed!"
fi;
done

# Separately check for protoc
version="$(protoc --version)" > /dev/null
if [[ $version =~ 'command not found' ]];
echo 'Protobuf is not installed. Attempting to install it.'
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.8.0/protobuf-cpp-3.8.0.zip
unzip protobuf-cpp-3.8.0.zip && cd protobuf-3.8.0
./configure
make && make check
sudo make install
sudo ldconfig
else
echo 'Protobuf is installed'
fi

file="~/comp4-software/"
if [ ! -f "$file"]
then
continue
else
echo "setting up project"
cd ~ && git clone https://github.com/ParadigmHyperloop/comp4-software.git
virtualenv -p python3 comp4-software/OnLand/.virtualenv
~/comp4-software/OnLand/ProtoBufs/UpdateProtos.sh
fi

# Creates the script that will be ran hourly by cron, and if a manual update is needed you can just run it
echo '
cd ~/comp4-software
git pull
source OnLand/.virtualenv/bin/activate
./ProtoBufs/UpdateProtos.sh
./OnLand/.virtualenv/bin/pip intall -r OnLand/requirements.txt
' >> ~/update.sh
chmod +x ~/update.sh

# create the cron job, that will run hourly
# REMEMBER TO CHANGE THE USER NAME
crontab -l > mycron
echo ' 0 * * * * /home/REPLACE_HERE/update.sh' >> cronjob
crontab cronjob

# Creates the system service that will run the OnLand software on boot
echo '
[Unit]
Description=Paradigm Hyperloop subsystem

[Service]
Type=simple
ExecStart=~/comp4-software/OnLand/.virtualenv/bin/python ~/comp4-software/OnLand/paradigm.py
StandardOutput= inherit

[Install]
WantedBy=multi-user.target
' > /etc/systemd/system/ called paradigm.service