mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-10 11:49:28 +00:00
Fix script errors in easyinstall.sh (#297)
* Fix minor errors in easyinstall.sh and start.sh * Make easyinstall directory portable * Remove directory check from easyinstall.sh * Revert to requiring the checkout dir to be /home/pi/RASCSI Co-authored-by: Daniel Markstedt <markstedt@gmail.com>
This commit is contained in:
parent
f7cdc917ad
commit
5bd8807c9e
@ -1,4 +1,4 @@
|
||||
#!/bin/bash
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# BSD 3-Clause License
|
||||
# Author @sonique6784
|
||||
@ -46,8 +46,9 @@ logo="""
|
||||
echo -e $logo
|
||||
}
|
||||
|
||||
VIRTUAL_DRIVER_PATH=/home/pi/images
|
||||
VIRTUAL_DRIVER_PATH="$HOME/images"
|
||||
CFG_PATH="$HOME/.config/rascsi"
|
||||
BASE="$HOME/RASCSI"
|
||||
HFS_FORMAT=/usr/bin/hformat
|
||||
HFDISK_BIN=/usr/bin/hfdisk
|
||||
LIDO_DRIVER=~/RASCSI/lido-driver.img
|
||||
@ -63,8 +64,8 @@ function initialChecks() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d ~/RASCSI ]; then
|
||||
echo "You must checkout RASCSI repo into /home/pi/RASCSI"
|
||||
if [ ! -d "$BASE" ]; then
|
||||
echo "You must checkout RASCSI repo into $BASE"
|
||||
echo "$ git clone git@github.com:akuker/RASCSI.git"
|
||||
exit 2
|
||||
fi
|
||||
@ -87,14 +88,15 @@ function installRaScsi() {
|
||||
SYSTEMD_BACKUP=false
|
||||
fi
|
||||
|
||||
cd ~/RASCSI/src/raspberrypi
|
||||
cd ~/RASCSI/src/raspberrypi || exit 1
|
||||
|
||||
make clean
|
||||
make all CONNECT_TYPE=${CONNECT_TYPE-FULLSPEC}
|
||||
sudo make install CONNECT_TYPE=${CONNECT_TYPE-FULLSPEC}
|
||||
make all CONNECT_TYPE="${CONNECT_TYPE-FULLSPEC}"
|
||||
sudo make install CONNECT_TYPE="${CONNECT_TYPE-FULLSPEC}"
|
||||
|
||||
sudoIsReady=$(sudo grep -c "rascsi" /etc/sudoers)
|
||||
|
||||
if [ $sudoIsReady = "0" ]; then
|
||||
if [ "$sudoIsReady" = "0" ]; then
|
||||
sudo bash -c 'echo "
|
||||
# Allow the web server to restart the rascsi service
|
||||
www-data ALL=NOPASSWD: /bin/systemctl restart rascsi.service
|
||||
@ -112,12 +114,14 @@ www-data ALL=NOPASSWD: /sbin/shutdown, /sbin/reboot
|
||||
|
||||
# install everything required to run an HTTP server (Nginx + Python Flask App)
|
||||
function installRaScsiWebInterface() {
|
||||
|
||||
if [ -f ~/RASCSI/src/web/rascsi_interface_pb2.py ]; then
|
||||
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="$BASE/src/raspberrypi/" --python_out="$BASE/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/502.html /var/www/html/502.html
|
||||
@ -135,20 +139,20 @@ function installRaScsiWebInterface() {
|
||||
}
|
||||
|
||||
function createImagesDir() {
|
||||
if [ -d $VIRTUAL_DRIVER_PATH ]; then
|
||||
if [ -d "$VIRTUAL_DRIVER_PATH" ]; then
|
||||
echo "The $VIRTUAL_DRIVER_PATH directory already exists."
|
||||
else
|
||||
echo "The $VIRTUAL_DRIVER_PATH directory does not exist; creating..."
|
||||
mkdir -p $VIRTUAL_DRIVER_PATH
|
||||
chmod -R 775 $VIRTUAL_DRIVER_PATH
|
||||
mkdir -p "$VIRTUAL_DRIVER_PATH"
|
||||
chmod -R 775 "$VIRTUAL_DRIVER_PATH"
|
||||
fi
|
||||
|
||||
if [ -d $CFG_PATH ]; then
|
||||
if [ -d "$CFG_PATH" ]; then
|
||||
echo "The $CFG_PATH directory already exists."
|
||||
else
|
||||
echo "The $CFG_PATH directory does not exist; creating..."
|
||||
mkdir -p $CFG_PATH
|
||||
chmod -R 775 $CFG_PATH
|
||||
mkdir -p "$CFG_PATH"
|
||||
chmod -R 775 "$CFG_PATH"
|
||||
fi
|
||||
}
|
||||
|
||||
@ -164,7 +168,7 @@ function stopOldWebInterface() {
|
||||
|
||||
function updateRaScsiGit() {
|
||||
echo "Updating checked out branch $GIT_REMOTE/$GIT_BRANCH"
|
||||
cd ~/RASCSI
|
||||
cd ~/RASCSI || exit 1
|
||||
stashed=0
|
||||
if [[ $(git diff --stat) != '' ]]; then
|
||||
echo 'There are local changes, we will stash and reapply them.'
|
||||
@ -217,7 +221,7 @@ function formatDrive() {
|
||||
if [ ! -x $HFDISK_BIN ]; then
|
||||
# Clone, compile and install 'hfdisk', partition tool
|
||||
git clone git://www.codesrc.com/git/hfdisk.git
|
||||
cd hfdisk
|
||||
cd hfdisk || exit 1
|
||||
make
|
||||
|
||||
sudo cp hfdisk /usr/bin/hfdisk
|
||||
@ -283,12 +287,12 @@ function createDrive() {
|
||||
|
||||
driveSize=$1
|
||||
driveName=$2
|
||||
mkdir -p $VIRTUAL_DRIVER_PATH
|
||||
mkdir -p "$VIRTUAL_DRIVER_PATH"
|
||||
drivePath="${VIRTUAL_DRIVER_PATH}/${driveSize}MB.hds"
|
||||
|
||||
if [ ! -f $drivePath ]; then
|
||||
if [ ! -f "$drivePath" ]; then
|
||||
echo "Creating a ${driveSize}MB Drive"
|
||||
truncate --size ${driveSize}m $drivePath
|
||||
truncate --size "${driveSize}m" "$drivePath"
|
||||
|
||||
echo "Formatting drive with HFS"
|
||||
formatDrive "$drivePath" "$driveName"
|
||||
@ -319,17 +323,17 @@ function setupWiredNetworking() {
|
||||
LAN_INTERFACE=$SELECTED
|
||||
fi
|
||||
|
||||
if [ $(grep -c "^denyinterfaces" /etc/dhcpcd.conf) -ge 1 ]; then
|
||||
if [ "$(grep -c "^denyinterfaces" /etc/dhcpcd.conf)" -ge 1 ]; then
|
||||
echo "WARNING: Network forwarding may already have been configured. Proceeding will overwrite the configuration."
|
||||
echo "Press enter to continue or CTRL-C to exit"
|
||||
read REPLY
|
||||
sudo sed -i /^denyinterfaces/d /etc/dhcpcd.conf
|
||||
fi
|
||||
sudo echo "denyinterfaces $LAN_INTERFACE" >> /etc/dhcpcd.conf
|
||||
sudo -c 'echo "denyinterfaces $LAN_INTERFACE" >> /etc/dhcpcd.conf'
|
||||
echo "Modified /etc/dhcpcd.conf"
|
||||
|
||||
# default config file is made for eth0, this will set the right net interface
|
||||
sudo bash -c 'sed s/eth0/'"$LAN_INTERFACE"'/g /home/pi/RASCSI/src/raspberrypi/os_integration/rascsi_bridge > /etc/network/interfaces.d/rascsi_bridge'
|
||||
sudo bash -c 'sed s/eth0/'"$LAN_INTERFACE"'/g '"$BASE"'/src/raspberrypi/os_integration/rascsi_bridge > /etc/network/interfaces.d/rascsi_bridge'
|
||||
echo "Modified /etc/network/interfaces.d/rascsi_bridge"
|
||||
|
||||
echo "Configuration completed!"
|
||||
@ -378,7 +382,7 @@ function setupWirelessNetworking() {
|
||||
fi
|
||||
|
||||
|
||||
if [ $(grep -c "^net.ipv4.ip_forward=1" /etc/sysctl.conf) -ge 1 ]; then
|
||||
if [ "$(grep -c "^net.ipv4.ip_forward=1" /etc/sysctl.conf)" -ge 1 ]; then
|
||||
echo "WARNING: Network forwarding may already have been configured. Proceeding will overwrite the configuration."
|
||||
echo "Press enter to continue or CTRL-C to exit"
|
||||
read REPLY
|
||||
@ -394,11 +398,11 @@ function setupWirelessNetworking() {
|
||||
sudo iptables -P INPUT ACCEPT
|
||||
sudo iptables -P OUTPUT ACCEPT
|
||||
sudo iptables -P FORWARD ACCEPT
|
||||
sudo iptables -t nat -A POSTROUTING -o $WLAN_INTERFACE -s $ROUTING_ADDRESS -j MASQUERADE
|
||||
sudo iptables -t nat -A POSTROUTING -o "$WLAN_INTERFACE" -s "$ROUTING_ADDRESS" -j MASQUERADE
|
||||
|
||||
# Check if iptables-persistent is installed
|
||||
IPTABLES_PERSISTENT=$(dpkg -s iptables-persistent | grep Status | grep -c "install ok")
|
||||
if [ $IPTABLES_PERSISTENT -eq 0 ]; then
|
||||
if [ "$IPTABLES_PERSISTENT" -eq 0 ]; then
|
||||
sudo apt-get install iptables-persistent --assume-yes
|
||||
else
|
||||
sudo iptables-save --file /etc/iptables/rules.v4
|
||||
@ -543,8 +547,8 @@ function showMenu() {
|
||||
|
||||
# parse arguments
|
||||
while [ "$1" != "" ]; do
|
||||
PARAM=`echo $1 | awk -F= '{print $1}'`
|
||||
VALUE=`echo $1 | awk -F= '{print $2}'`
|
||||
PARAM=$(echo "$1" | awk -F= '{print $1}')
|
||||
VALUE=$(echo "$1" | awk -F= '{print $2}')
|
||||
case $PARAM in
|
||||
-c | --connect_type)
|
||||
CONNECT_TYPE=$VALUE
|
||||
|
@ -2,7 +2,7 @@
|
||||
set -e
|
||||
# set -x # Uncomment to Debug
|
||||
|
||||
cd $(dirname $0)
|
||||
cd "$(dirname "$0")"
|
||||
# verify packages installed
|
||||
ERROR=0
|
||||
if ! command -v genisoimage &> /dev/null ; then
|
||||
|
Loading…
Reference in New Issue
Block a user