mirror of
https://github.com/akuker/RASCSI.git
synced 2024-06-02 11:41:34 +00:00
Back up rascsi.service before installing new one (#273)
* Back up rascsi.service before installing new one * Error out on errors * Extra notification to user that rascsi.service has been overwritten
This commit is contained in:
parent
bfdaec6c15
commit
7e456b76bf
|
@ -53,6 +53,8 @@ LIDO_DRIVER=~/RASCSI/lido-driver.img
|
||||||
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||||
GIT_REMOTE=${GIT_REMOTE:-origin}
|
GIT_REMOTE=${GIT_REMOTE:-origin}
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
function initialChecks() {
|
function initialChecks() {
|
||||||
currentUser=$(whoami)
|
currentUser=$(whoami)
|
||||||
if [ "pi" != "$currentUser" ]; then
|
if [ "pi" != "$currentUser" ]; then
|
||||||
|
@ -76,6 +78,14 @@ function installPackages() {
|
||||||
function installRaScsi() {
|
function installRaScsi() {
|
||||||
sudo systemctl stop rascsi
|
sudo systemctl stop rascsi
|
||||||
|
|
||||||
|
if [ -f /etc/systemd/system/rascsi.service ]; then
|
||||||
|
sudo cp /etc/systemd/system/rascsi.service /etc/systemd/system/rascsi.service.old
|
||||||
|
SYSTEMD_BACKUP=true
|
||||||
|
echo "Existing version of rascsi.service detected; Backing up to rascsi.service.old"
|
||||||
|
else
|
||||||
|
SYSTEMD_BACKUP=false
|
||||||
|
fi
|
||||||
|
|
||||||
cd ~/RASCSI/src/raspberrypi
|
cd ~/RASCSI/src/raspberrypi
|
||||||
make clean
|
make clean
|
||||||
make all CONNECT_TYPE=${CONNECT_TYPE-FULLSPEC}
|
make all CONNECT_TYPE=${CONNECT_TYPE-FULLSPEC}
|
||||||
|
@ -93,6 +103,7 @@ www-data ALL=NOPASSWD: /sbin/shutdown, /sbin/reboot
|
||||||
" >> /etc/sudoers'
|
" >> /etc/sudoers'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl restart rsyslog
|
sudo systemctl restart rsyslog
|
||||||
sudo systemctl enable rascsi # optional - start rascsi at boot
|
sudo systemctl enable rascsi # optional - start rascsi at boot
|
||||||
sudo systemctl start rascsi
|
sudo systemctl start rascsi
|
||||||
|
@ -100,8 +111,11 @@ www-data ALL=NOPASSWD: /sbin/shutdown, /sbin/reboot
|
||||||
|
|
||||||
# install everything required to run an HTTP server (Nginx + Python Flask App)
|
# install everything required to run an HTTP server (Nginx + Python Flask App)
|
||||||
function installRaScsiWebInterface() {
|
function installRaScsiWebInterface() {
|
||||||
echo "Compiling the Python protobuf library..."
|
if [ -f ~/RASCSI/src/web/rascsi_interface_pb2.py ]; then
|
||||||
[ -f ~/RASCSI/src/web/rascsi_interface.proto ] && rm ~/RASCSI/src/web/rascsi_interface.proto
|
rm ~/RASCSI/src/web/rascsi_interface_pb2.py
|
||||||
|
echo "Deleting old Python protobuf library rascsi_interface_pb2.py"
|
||||||
|
fi
|
||||||
|
echo "Compiling the Python protobuf library rascsi_interface_pb2.py..."
|
||||||
protoc -I=/home/pi/RASCSI/src/raspberrypi/ --python_out=/home/pi/RASCSI/src/web/ rascsi_interface.proto
|
protoc -I=/home/pi/RASCSI/src/raspberrypi/ --python_out=/home/pi/RASCSI/src/web/ rascsi_interface.proto
|
||||||
|
|
||||||
sudo cp -f ~/RASCSI/src/web/service-infra/nginx-default.conf /etc/nginx/sites-available/default
|
sudo cp -f ~/RASCSI/src/web/service-infra/nginx-default.conf /etc/nginx/sites-available/default
|
||||||
|
@ -418,6 +432,16 @@ function reserveScsiIds() {
|
||||||
sudo systemctl start rascsi
|
sudo systemctl start rascsi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function notifyBackup {
|
||||||
|
if $SYSTEMD_BACKUP; then
|
||||||
|
echo ""
|
||||||
|
echo "IMPORTANT: /etc/systemd/system/rascsi.service has been overwritten."
|
||||||
|
echo "A backup copy was saved as rascsi.service.old in the same directory."
|
||||||
|
echo "Please inspect the backup file and restore configurations that are important to your setup."
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function runChoice() {
|
function runChoice() {
|
||||||
case $1 in
|
case $1 in
|
||||||
1)
|
1)
|
||||||
|
@ -430,6 +454,7 @@ function runChoice() {
|
||||||
installRaScsiWebInterface
|
installRaScsiWebInterface
|
||||||
showRaScsiStatus
|
showRaScsiStatus
|
||||||
showRaScsiWebStatus
|
showRaScsiWebStatus
|
||||||
|
notifyBackup
|
||||||
echo "Installing / Updating RaSCSI Service (${CONNECT_TYPE-FULLSPEC}) + Web interface - Complete!"
|
echo "Installing / Updating RaSCSI Service (${CONNECT_TYPE-FULLSPEC}) + Web interface - Complete!"
|
||||||
;;
|
;;
|
||||||
2)
|
2)
|
||||||
|
@ -439,6 +464,7 @@ function runChoice() {
|
||||||
installPackages
|
installPackages
|
||||||
installRaScsi
|
installRaScsi
|
||||||
showRaScsiStatus
|
showRaScsiStatus
|
||||||
|
notifyBackup
|
||||||
echo "Installing / Updating RaSCSI Service (${CONNECT_TYPE-FULLSPEC}) - Complete!"
|
echo "Installing / Updating RaSCSI Service (${CONNECT_TYPE-FULLSPEC}) - Complete!"
|
||||||
;;
|
;;
|
||||||
3)
|
3)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user