-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from hudsonvalleydigitalnetwork/develop
Develop to Master (v0.5.0 Release)
- Loading branch information
Showing
53 changed files
with
4,665 additions
and
1,203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,283 @@ | ||
#!/bin/bash | ||
|
||
### | ||
### HASviolet.sh | ||
### | ||
### | ||
|
||
### | ||
### REVISION: 20220714-0300 | ||
### | ||
|
||
### | ||
### Usage: HASviolet [COMMAND] [OPTION] | ||
### | ||
### COMMAND OPTION | ||
### | ||
### install install current release | ||
### config configure HASviolet | ||
### refresh reset HASviolet back to install (remove/new configs) | ||
### remove remove HASviolet | ||
### purge remove HASviolet and purge configs | ||
### update upgrade to new version if available (git pull) | ||
### websox | ||
### install Install Web Interface | ||
### start Start Web Interface | ||
### stop Stop Web Interface | ||
### status Web Interface Status | ||
### removde Remove and disable Web Interface | ||
|
||
|
||
### | ||
### | ||
### HASviolet has been designed for the following hardware: | ||
### Raspberry Pi Zero Wireless | ||
### Adafruit LoRa Radio Bonnet with OLED RFM95W @ 915 MHz https://www.adafruit.com/product/4074 | ||
### Sensors connected via i2c | ||
### GPS USB modules | ||
### | ||
### Generic Python Libraries for i2c and SPI are installed as well as the following: | ||
### | ||
### Adafruit RFM9X Library | ||
### https://github.com/adafruit/adafruit-circuitpython-rfm9x | ||
### | ||
### Adafruit Monochrome OLEDs based on SSD1306 drivers | ||
### https://github.com/adafruit/Adafruit_SSD1306 | ||
### | ||
### Adafruit_CircuitPython_framebuf | ||
### https://github.com/adafruit/Adafruit_CircuitPython_framebuf | ||
### | ||
### Sparkfun Qwiic Python Package | ||
### https://github.com/sparkfun/Qwiic_Py | ||
### | ||
### pyRF95 | ||
### https://github.com/ladecadence/pyRF95 | ||
### | ||
### | ||
### | ||
|
||
## | ||
## INIT VARIABLES AND DIRECTORIES | ||
## | ||
|
||
# HASviolet Directory tree | ||
HASVIOLET_REPO="https://github.com/hudsonvalleydigitalnetwork/hasviolet.git" | ||
HASVIOLET_HOME=$HOME/hasviolet | ||
HASVIOLET_TEMPLATES=$HASVIOLET_HOME/templates | ||
HASVIOLET_TEMPLATES_ETC=$HASVIOLET_TEMPLATES/etc | ||
HASVIOLET_TEMPLATES_SRV=$HASVIOLET_TEMPLATES/server | ||
HASVIOLET_LOCAL=$HOME/hasviolet-local | ||
HASVIOLET_SERVER=$HASVIOLET_LOCAL/server | ||
HASVIOLET_ETC=$HASVIOLET_LOCAL/etc | ||
HASVIOLET_CONFIG=$HASVIOLET_ETC/HASviolet.json | ||
HASVIOLET_SSL_KEY=$HASVIOLET_ETC/HASviolet.key | ||
HASVIOLET_SSL_CRT=$HASVIOLET_ETC/HASviolet.crt | ||
HASVIOLET_BANNER_COLOR="\e[0;104m\e[K" # blue | ||
HASVIOLET_BANNER_RESET="\e[0m" | ||
|
||
# HASviolet Install Support files | ||
|
||
# Detect architecture (x86, x86_64, aarch64, ARMv8, ARMv7) | ||
HASVIOLET_HWARCH=`lscpu|grep Architecture|awk '{print $2}'` | ||
# Detect Operating system (Raspberry Pi OS) | ||
HASVIOLET_OSNAME=`cat /etc/os-release|grep "PRETTY_NAME"|awk -F'"' '{print $2}'` | ||
# Is Platform good for install- true or false - we start with false | ||
HASVIOLET_CERTIFIED="false" | ||
|
||
|
||
### | ||
### FUNCTIONS | ||
### | ||
|
||
hasviolet_install(){ | ||
echo " " | ||
echo "HASviolet Install" | ||
echo " " | ||
echo "- Install Dependencoes" | ||
echo " " | ||
sudo apt-get -y install git | ||
sudo apt-get -y install python3-pip | ||
sudo apt-get -y install python3-pil | ||
sudo apt-get -y install libatlas-base-dev # Numpy Dependency | ||
echo " " | ||
echo "- Install Libraries" | ||
echo " " | ||
sudo pip3 install tornado | ||
sudo pip3 install RPI.GPIO | ||
sudo pip3 install spidev | ||
sudo pip3 install pynmea2 | ||
sudo pip3 install python-metar | ||
sudo pip3 install adafruit-circuitpython-ssd1306 | ||
sudo pip3 install adafruit-circuitpython-framebuf | ||
sudo pip3 install adafruit-circuitpython-rfm9x | ||
sudo pip3 install numpy # pyLoraRFM9x dependency | ||
sudo pip3 install pyLoraRFM9x | ||
sudo pip3 install sparkfun-qwiic | ||
sudo pip3 install sparkfun-qwiic-bme280 | ||
sudo pip3 install sparkfun-qwiic-vl53l1x | ||
echo " " | ||
echo "- Create Directories" | ||
echo " " | ||
cd $HASVIOLET_HOME | ||
mkdir $HASVIOLET_LOCAL | ||
mkdir $HASVIOLET_ETC | ||
echo " " | ||
echo "- Copy config templates into $HASVIOLET_ETC" | ||
echo " " | ||
cp $HASVIOLET_TEMPLATES_ETC/* $HASVIOLET_ETC | ||
echo " " | ||
echo "- Generating self-signed SSL certificate -- /C=US/ST=New York/L=Hudson Valley/O=Hudson Valley Digital Network/OU=HASviolet/CN=hvdn.org" | ||
echo " " | ||
sudo openssl req -x509 -nodes -days 1095 -newkey rsa:2048 -subj "/C=US/ST=New York/L=Hudson Valley/O=Hudson Valley Digital Network/OU=HASviolet/CN=hvdn.org" -keyout $HASVIOLET_SSL_KEY -out $HASVIOLET_SSL_CRT | ||
sudo chown pi:pi $HASVIOLET_SSL_KEY >/dev/null 2>&1 | ||
sudo chown pi:pi $HASVIOLET_SSL_CRT >/dev/null 2>&1 | ||
echo " " | ||
echo "HASviolet Install complete" | ||
echo " " | ||
} | ||
|
||
hasviolet_refresh(){ | ||
echo " " | ||
echo "- Remove Config Directory" | ||
echo " " | ||
cd $HOME | ||
sudo rm -rf $HASVIOLET_ETC | ||
|
||
echo " " | ||
echo "- Create Config Directory" | ||
echo " " | ||
cd $HOME | ||
mkdir $HASVIOLET_ETC | ||
echo " " | ||
echo "- Copy config templates into $HASVIOLET_ETC" | ||
echo " " | ||
cp $HASVIOLET_TEMPLATES_ETC/* $HASVIOLET_ETC | ||
echo " " | ||
echo "- Generating self-signed SSL certificate -- /C=US/ST=New York/L=Hudson Valley/O=Hudson Valley Digital Network/OU=HASviolet/CN=hvdn.org" | ||
echo " " | ||
sudo openssl req -x509 -nodes -days 1095 -newkey rsa:2048 -subj "/C=US/ST=New York/L=Hudson Valley/O=Hudson Valley Digital Network/OU=HASviolet/CN=hvdn.org" -keyout $HASVIOLET_SSL_KEY -out $HASVIOLET_SSL_CRT | ||
sudo chown pi:pi $HASVIOLET_SSL_KEY >/dev/null 2>&1 | ||
sudo chown pi:pi $HASVIOLET_SSL_CRT >/dev/null 2>&1 | ||
|
||
echo " " | ||
echo "HASviolet Install complete" | ||
echo " " | ||
} | ||
|
||
hasviolet_update(){ | ||
echo " " | ||
echo "HASviolet Update" | ||
echo " " | ||
cd $HASVIOLET_HOME | ||
git pull | ||
cat RELEASE |more | ||
} | ||
|
||
|
||
### | ||
### MAIN | ||
### | ||
|
||
KOMMAND=$1 | ||
KOPTION=$2 | ||
|
||
case "$KOMMAND" in | ||
install) | ||
hasviolet_install | ||
;; | ||
config) | ||
python $HASVIOLET_HOME/HASviolet_config.py | ||
;; | ||
remove) | ||
echo -e "${HASVIOLET_BANNER_COLOR}" | ||
echo -e "${HASVIOLET_BANNER_COLOR} ## Remove HASviolet" | ||
echo -e "${HASVIOLET_BANNER_RESET}" | ||
cd ~ | ||
rm -rf $HASVIOLET_HOME | ||
;; | ||
purge) | ||
echo -e "${HASVIOLET_BANNER_COLOR}" | ||
echo -e "${HASVIOLET_BANNER_COLOR} ## Purge HASviolet" | ||
echo -e "${HASVIOLET_BANNER_RESET}" | ||
cd ~ | ||
rm -rf $HASVIOLET_HOME | ||
rm -rf $HASVIOLET_LOCAL | ||
;; | ||
update) | ||
hasviolet_update | ||
;; | ||
refresh) | ||
hasviolet_refresh | ||
;; | ||
RX) | ||
python $HASVIOLET_HOME/HASviolet_RX.py -s | ||
;; | ||
CHAT) | ||
python $HASVIOLET_HOME/HASviolet_CHAT.py | ||
;; | ||
TX) | ||
FIRSTARG=$1 | ||
shift 1 | ||
ALLARGS=$@ | ||
python $HASVIOLET_HOME/HASviolet_TX.py -c 1 -t 1 -d $FIRSTARG -m "$ALLARGS" | ||
;; | ||
BEACON) | ||
# Beacon forever every 5 seconds | ||
if [ -z $2 ]; then | ||
python $HASVIOLET_HOME/HASviolet_TX.py -c 99999 -t 5 | ||
else | ||
shift 1 | ||
FIRSTARG=$1 | ||
shift 1 | ||
ALLARGS=$@ | ||
python $HASVIOLET_HOME/HASviolet_TX.py -c 99999 -t 5 -d $FIRSTARG -m "$ALLARGS" | ||
fi | ||
;; | ||
websox) | ||
case "$KOPTION" in | ||
status) | ||
sudo systemctl status HASviolet_websox.service | ||
;; | ||
start) | ||
sudo systemctl start HASviolet_websox.service | ||
;; | ||
stop) | ||
sudo systemctl stop HASviolet_websox.service | ||
;; | ||
remove) | ||
sudo systemctl stop HASviolet_websox.service | ||
sudo systemctl disable HASviolet_websox.service | ||
sudo rm -rf /lib/systemd/system/HASviolet_websox.service | ||
sudo rm -rf $HASVIOLET_SERVER | ||
;; | ||
install) | ||
# Make $HOME/hasviolet-local/server | ||
mkdir $HASVIOLET_SERVER | ||
# Copy Web Server files into $HASVIOLET_SERVER | ||
cp -r $HASVIOLET_TEMPLATES_SRV/* $HASVIOLET_SERVER | ||
# Creat Web Server CFG dir and copy config into it | ||
mkdir $HASVIOLET_SERVER/cfg | ||
cp $HASVIOLET_CONFIG $HASVIOLET_SERVER/cfg | ||
cp $HASVIOLET_HOME/HASrf95.py $HASVIOLET_SERVER | ||
cp $HASVIOLET_HOME/HASvioletHID.py $HASVIOLET_SERVER | ||
cp $HASVIOLET_HOME/font5x8.bin $HASVIOLET_SERVER | ||
cp $HASVIOLET_HOME/HASvioletRF.py $HASVIOLET_SERVER | ||
# Copy and install Web Server service | ||
sudo cp $HASVIOLET_SERVER/HASviolet_websox.service /lib/systemd/system/HASviolet_websox.service | ||
sudo chown root:root /lib/systemd/system/HASviolet_websox.service | ||
sudo chmod 644 /lib/systemd/system/HASviolet_websox.service | ||
sudo systemctl daemon-reload | ||
sudo systemctl enable HASviolet_websox.service | ||
sudo systemctl start HASviolet_websox.service | ||
;; | ||
esac | ||
;; | ||
*) | ||
echo -e "${HASVIOLET_BANNER_COLOR}" | ||
echo -e "${HASVIOLET_BANNER_COLOR} ## ERROR: Unkown action or package" | ||
echo -e "${HASVIOLET_BANNER_COLOR}" | ||
echo -e "${HASVIOLET_BANNER_RESET}" | ||
;; | ||
esac | ||
|
||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.