2021-10-07 19:00:49 -06:00
#!/usr/bin/env bash
2020-10-26 10:55:53 +11:00
# BSD 3-Clause License
# Author @sonique6784
# Copyright (c) 2020, sonique6784
2020-11-08 11:10:09 +11:00
function showRaSCSILogo( ) {
logo = "" "
.~~. .~~.\n
'. \ ' ' / .'\n
.╔═══════╗.\n
: ║|¯¯¯¯¯|║ :\n
~ (║|_____|║) ~\n
( : ║ . __ ║ : )\n
~ .╚╦═════╦╝. ~\n
( ¯¯¯¯¯¯¯ ) RaSCSI Assistant\n
'~ .~~~. ~'\n
'~'\n
" ""
echo -e $logo
}
2020-10-26 10:55:53 +11:00
2021-09-14 19:51:12 -07:00
function showMacNetworkWired( ) {
logo = "" "
.-~-.-~~~-.~-.\n
╔═══════╗ .( )\n
║|¯¯¯¯¯|║ / \`.\n
║|_____|║>--------------<~ . )\n
║ . __ ║ ( :'-'\n
╚╦═════╦╝ ~-.________.:'\n
¯¯¯¯¯¯¯\n
" ""
echo -e $logo
}
function showMacNetworkWireless( ) {
logo = "" "
.-~-.-~~~-.~-.\n
╔═══════╗ .( .( )\n
║|¯¯¯¯¯|║ .( .( / \`.\n
║|_____|║ .o o ~ . )\n
║ . __ ║ '( '( ( :'-'\n
╚╦═════╦╝ '( ~-.________.:'\n
¯¯¯¯¯¯¯\n
" ""
echo -e $logo
}
2021-11-08 18:33:33 -08:00
USER = $( whoami)
BASE = $( dirname " $( readlink -f " ${ 0 } " ) " )
2021-10-07 19:00:49 -06:00
VIRTUAL_DRIVER_PATH = " $HOME /images "
2021-10-05 18:58:49 -07:00
CFG_PATH = " $HOME /.config/rascsi "
2021-12-02 17:18:45 -08:00
WEB_INSTALL_PATH = " $BASE /src/web "
SYSTEMD_PATH = "/etc/systemd/system"
2020-11-08 11:10:09 +11:00
HFS_FORMAT = /usr/bin/hformat
HFDISK_BIN = /usr/bin/hfdisk
2021-10-13 18:01:13 -07:00
LIDO_DRIVER = $BASE /lido-driver.img
2021-03-07 09:52:04 -06:00
GIT_BRANCH = $( git rev-parse --abbrev-ref HEAD)
2021-07-31 10:52:09 -05:00
GIT_REMOTE = ${ GIT_REMOTE :- origin }
2021-12-23 09:12:16 -08:00
TOKEN = ""
2020-10-26 10:55:53 +11:00
2021-09-28 10:56:14 -07:00
set -e
2021-11-18 18:17:24 -08:00
# checks to run before entering the script main menu
2021-11-14 11:57:38 -08:00
function initialChecks( ) {
if [ "root" = = " $USER " ] ; then
echo " Do not run this script as $USER or with 'sudo'. "
exit 1
fi
}
2021-11-18 18:17:24 -08:00
# checks that the current user has sudoers privileges
function sudoCheck( ) {
echo "Input your password to allow this script to make the above changes."
sudo -v
}
2021-09-14 19:51:12 -07:00
# install all dependency packages for RaSCSI Service
2021-02-01 12:24:59 -06:00
function installPackages( ) {
2021-12-19 15:28:22 -08:00
sudo apt-get update && sudo apt-get install git libspdlog-dev libpcap-dev genisoimage python3 python3-venv python3-dev python3-pip nginx libpcap-dev protobuf-compiler bridge-utils libev-dev libevdev2 -y </dev/null
2021-02-01 12:24:59 -06:00
}
2020-10-26 10:55:53 +11:00
2021-11-18 18:17:24 -08:00
# compile the RaSCSI binaries
function compileRaScsi( ) {
2021-10-13 18:01:13 -07:00
cd " $BASE /src/raspberrypi " || exit 1
2020-10-26 10:55:53 +11:00
2021-11-18 18:17:24 -08:00
echo " Compiling with ${ CORES :- 1 } simultaneous cores... "
2021-12-20 12:50:14 -06:00
( make clean && make -j " ${ CORES :- 1 } " all CONNECT_TYPE = " ${ CONNECT_TYPE :- FULLSPEC } " ) </dev/null
2021-11-18 18:17:24 -08:00
}
2021-10-20 22:06:00 -07:00
2021-11-18 18:17:24 -08:00
# install the RaSCSI binaries and modify the service configuration
function installRaScsi( ) {
sudo make install CONNECT_TYPE = " ${ CONNECT_TYPE :- FULLSPEC } " </dev/null
2020-12-30 19:39:32 -06:00
}
2020-10-26 10:55:53 +11:00
2020-12-30 19:39:32 -06:00
# install everything required to run an HTTP server (Nginx + Python Flask App)
function installRaScsiWebInterface( ) {
2021-12-02 17:18:45 -08:00
if [ -f " $WEB_INSTALL_PATH /rascsi_interface_pb2.py " ] ; then
sudo rm " $WEB_INSTALL_PATH /rascsi_interface_pb2.py "
2021-11-18 18:17:24 -08:00
echo "Deleting old Python protobuf library rascsi_interface_pb2.py"
2021-09-28 10:56:14 -07:00
fi
echo "Compiling the Python protobuf library rascsi_interface_pb2.py..."
2021-12-02 17:18:45 -08:00
protoc -I= " $BASE /src/raspberrypi/ " --python_out= " $WEB_INSTALL_PATH " rascsi_interface.proto
2021-10-07 19:00:49 -06:00
2021-10-13 18:01:13 -07:00
sudo cp -f " $BASE /src/web/service-infra/nginx-default.conf " /etc/nginx/sites-available/default
sudo cp -f " $BASE /src/web/service-infra/502.html " /var/www/html/502.html
2020-10-26 10:55:53 +11:00
2021-11-08 18:33:33 -08:00
sudo usermod -a -G $USER www-data
2020-10-26 10:55:53 +11:00
2021-11-18 18:17:24 -08:00
sudo systemctl reload nginx || true
2020-12-30 19:39:32 -06:00
}
2020-10-26 10:55:53 +11:00
2021-11-18 18:17:24 -08:00
# updates configuration files and installs packages needed for the OLED screen script
2021-10-19 20:16:11 -07:00
function installRaScsiScreen( ) {
echo "IMPORTANT: This configuration requires a OLED screen to be installed onto your RaSCSI board."
echo "See wiki for more information: https://github.com/akuker/RASCSI/wiki/OLED-Status-Display-(Optional)"
echo ""
2021-11-13 17:40:49 -08:00
echo "Choose screen rotation:"
echo " 1) 0 degrees"
echo " 2) 180 degrees (default)"
2021-10-19 20:16:11 -07:00
read REPLY
2021-11-13 17:40:49 -08:00
if [ " $REPLY " = = "1" ] ; then
2021-10-20 19:33:06 -07:00
echo "Proceeding with 0 degrees rotation."
ROTATION = "0"
else
echo "Proceeding with 180 degrees rotation."
ROTATION = "180"
fi
2021-11-13 17:40:49 -08:00
echo ""
echo "Choose screen resolution:"
echo " 1) 128x32 pixels (default)"
echo " 2) 128x64 pixels"
read REPLY
if [ " $REPLY " = = "2" ] ; then
echo "Proceeding with 128x64 pixel resolution."
SCREEN_HEIGHT = "64"
else
echo "Proceeding with 128x32 pixel resolution."
SCREEN_HEIGHT = "32"
fi
2022-01-01 09:38:10 -08:00
if [ -z " $TOKEN " ] ; then
echo ""
echo "Did you protect your RaSCSI installation with a token password? [y/N]"
read -r REPLY
if [ " $REPLY " = = "y" ] || [ " $REPLY " = = "Y" ] ; then
echo -n "Enter the password that you configured with RaSCSI at the time of installation: "
read -r TOKEN
fi
2021-12-23 09:12:16 -08:00
fi
2021-10-20 22:06:00 -07:00
stopRaScsiScreen
2021-10-19 20:16:11 -07:00
updateRaScsiGit
2021-12-19 15:28:22 -08:00
sudo apt-get update && sudo apt-get install libjpeg-dev libpng-dev libopenjp2-7-dev i2c-tools raspi-config -y </dev/null
2021-10-19 20:16:11 -07:00
if [ -f " $BASE /src/oled_monitor/rascsi_interface_pb2.py " ] ; then
2021-11-14 11:57:38 -08:00
sudo rm " $BASE /src/oled_monitor/rascsi_interface_pb2.py "
2021-10-19 20:16:11 -07:00
echo "Deleting old Python protobuf library rascsi_interface_pb2.py"
fi
echo "Compiling the Python protobuf library rascsi_interface_pb2.py..."
protoc -I= " $BASE /src/raspberrypi/ " --python_out= " $BASE /src/oled_monitor " rascsi_interface.proto
if [ [ $( grep -c "^dtparam=i2c_arm=on" /boot/config.txt) -ge 1 ] ] ; then
echo "NOTE: I2C support seems to have been configured already."
REBOOT = 0
else
2021-10-28 11:16:48 -07:00
sudo raspi-config nonint do_i2c 0 </dev/null
2021-10-28 11:15:16 -07:00
echo "Modified the Raspberry Pi boot configuration to enable I2C."
2021-10-28 11:17:33 -07:00
echo "A reboot will be required for the change to take effect."
2021-10-19 20:16:11 -07:00
REBOOT = 1
fi
echo "Installing the monitor_rascsi.service configuration..."
2021-12-02 17:18:45 -08:00
sudo cp -f " $BASE /src/oled_monitor/monitor_rascsi.service " " $SYSTEMD_PATH /monitor_rascsi.service "
sudo sed -i /^ExecStart= /d " $SYSTEMD_PATH /monitor_rascsi.service "
2021-12-23 09:12:16 -08:00
if [ ! -z " $TOKEN " ] ; then
sudo sed -i " 8 i ExecStart= $BASE /src/oled_monitor/start.sh --rotation= $ROTATION --height= $SCREEN_HEIGHT --password= $TOKEN " " $SYSTEMD_PATH /monitor_rascsi.service "
sudo chmod 600 " $SYSTEMD_PATH /monitor_rascsi.service "
2022-01-01 09:38:10 -08:00
echo "Granted access to the OLED Monitor with the password that you configured for RaSCSI."
2021-12-23 09:12:16 -08:00
else
sudo sed -i " 8 i ExecStart= $BASE /src/oled_monitor/start.sh --rotation= $ROTATION --height= $SCREEN_HEIGHT " " $SYSTEMD_PATH /monitor_rascsi.service "
fi
2021-10-19 20:16:11 -07:00
sudo systemctl daemon-reload
sudo systemctl enable monitor_rascsi
if [ $REBOOT -eq 1 ] ; then
echo ""
echo "The monitor_rascsi service will start on the next Pi boot."
echo "Press Enter to reboot or CTRL-C to exit"
read
echo "Rebooting..."
sleep 3
sudo reboot
fi
sudo systemctl start monitor_rascsi
}
2021-11-18 18:17:24 -08:00
# Creates the dir that RaSCSI uses to store image files
2021-09-14 19:51:12 -07:00
function createImagesDir( ) {
2021-10-07 19:00:49 -06:00
if [ -d " $VIRTUAL_DRIVER_PATH " ] ; then
2021-09-14 19:51:12 -07:00
echo " The $VIRTUAL_DRIVER_PATH directory already exists. "
else
echo " The $VIRTUAL_DRIVER_PATH directory does not exist; creating... "
2021-10-07 19:00:49 -06:00
mkdir -p " $VIRTUAL_DRIVER_PATH "
chmod -R 775 " $VIRTUAL_DRIVER_PATH "
2021-09-14 19:51:12 -07:00
fi
2021-11-18 18:17:24 -08:00
}
2021-10-05 18:58:49 -07:00
2021-11-18 18:17:24 -08:00
# Creates the dir that the Web Interface uses to store configuration files
function createCfgDir( ) {
2021-10-07 19:00:49 -06:00
if [ -d " $CFG_PATH " ] ; then
2021-10-05 18:58:49 -07:00
echo " The $CFG_PATH directory already exists. "
else
echo " The $CFG_PATH directory does not exist; creating... "
2021-10-07 19:00:49 -06:00
mkdir -p " $CFG_PATH "
chmod -R 775 " $CFG_PATH "
2021-10-05 18:58:49 -07:00
fi
2021-09-14 19:51:12 -07:00
}
2021-11-18 18:17:24 -08:00
# Stops the rascsi-web and apache2 processes
2021-09-14 19:51:12 -07:00
function stopOldWebInterface( ) {
2021-10-20 22:06:00 -07:00
stopRaScsiWeb
2021-09-14 19:51:12 -07:00
APACHE_STATUS = $( sudo systemctl status apache2 & > /dev/null; echo $? )
if [ " $APACHE_STATUS " -eq 0 ] ; then
echo "Stopping old Apache2 RaSCSI Web..."
sudo systemctl disable apache2
sudo systemctl stop apache2
fi
}
2021-11-18 18:17:24 -08:00
# Checks for upstream changes to the git repo and fast-forwards changes if needed
2020-12-30 19:39:32 -06:00
function updateRaScsiGit( ) {
2021-10-13 18:01:13 -07:00
cd " $BASE " || exit 1
2021-12-23 09:08:50 -08:00
set +e
git rev-parse --is-inside-work-tree & > /dev/null
if [ [ $? -ge 1 ] ] ; then
echo "Warning: This does not seem to be a valid clone of a git repository. I will not be able to pull the latest code."
return 0
fi
set -e
2021-07-31 10:52:09 -05:00
stashed = 0
if [ [ $( git diff --stat) != '' ] ] ; then
2021-10-13 18:01:13 -07:00
echo "There are local changes to the RaSCSI code; we will stash and reapply them."
git -c user.name= " ${ GIT_COMMITTER_NAME -rascsi } " -c user.email= " ${ GIT_COMMITTER_EMAIL -rascsi@rascsi.com } " stash
2021-07-31 10:52:09 -05:00
stashed = 1
fi
2021-10-13 18:01:13 -07:00
if [ [ ` git for -each-ref --format= '%(upstream:short)' " $( git symbolic-ref -q HEAD) " ` != "" ] ] ; then
echo " Updating checked out git branch $GIT_REMOTE / $GIT_BRANCH "
git pull --ff-only
else
echo "Detected a local git working branch; skipping the remote update step."
fi
2021-07-31 10:52:09 -05:00
if [ $stashed -eq 1 ] ; then
echo "Reapplying local changes..."
git stash apply
fi
2020-12-30 19:39:32 -06:00
}
2020-10-26 10:55:53 +11:00
2021-11-18 18:17:24 -08:00
# Takes a backup copy of the rascsi.service file if it exists
function backupRaScsiService( ) {
2021-12-02 17:18:45 -08:00
if [ -f " $SYSTEMD_PATH /rascsi.service " ] ; then
sudo mv " $SYSTEMD_PATH /rascsi.service " " $SYSTEMD_PATH /rascsi.service.old "
2021-11-18 18:17:24 -08:00
SYSTEMD_BACKUP = true
echo "Existing version of rascsi.service detected; Backing up to rascsi.service.old"
else
SYSTEMD_BACKUP = false
fi
}
2022-01-01 09:38:10 -08:00
# Offers the choice of enabling token-based authentication for RaSCSI
function configureTokenAuth( ) {
2021-12-23 09:12:16 -08:00
echo ""
2022-01-01 09:38:10 -08:00
echo "Do you want to protect your RaSCSI installation with a password? [y/N]"
2021-12-23 09:12:16 -08:00
read REPLY
if [ " $REPLY " = = "y" ] || [ " $REPLY " = = "Y" ] ; then
2022-01-01 09:38:10 -08:00
echo -n "Enter the password that you want to use: "
2021-12-23 09:12:16 -08:00
read -r TOKEN
if [ -f " $HOME /.rascsi_secret " ] ; then
sudo rm " $HOME /.rascsi_secret "
echo "Removed old RaSCSI token file"
fi
echo " $TOKEN " > " $HOME /.rascsi_secret "
sudo chown root:root " $HOME /.rascsi_secret "
sudo chmod 600 " $HOME /.rascsi_secret "
2022-01-01 09:38:10 -08:00
echo ""
echo " Configured RaSCSI to use $HOME /.rascsi_secret for authentication. This file is readable by root only. "
echo "Make note of your password: you will need it to use rasctl and other RaSCSI clients."
fi
}
# Modifies and installs the rascsi service
function enableRaScsiService( ) {
if [ ! -z " $TOKEN " ] ; then
2021-12-23 09:12:16 -08:00
sudo sed -i " s@^ExecStart.*@& -F $VIRTUAL_DRIVER_PATH -P $HOME /.rascsi_secret@ " " $SYSTEMD_PATH /rascsi.service "
sudo chmod 600 " $SYSTEMD_PATH /rascsi.service "
else
sudo sed -i " s@^ExecStart.*@& -F $VIRTUAL_DRIVER_PATH @ " " $SYSTEMD_PATH /rascsi.service "
fi
2021-11-18 18:17:24 -08:00
echo " Configured rascsi.service to use $VIRTUAL_DRIVER_PATH as default image dir. "
sudo systemctl daemon-reload
sudo systemctl restart rsyslog
sudo systemctl enable rascsi # optional - start rascsi at boot
sudo systemctl start rascsi
}
# Modifies and installs the rascsi-web service
function installWebInterfaceService( ) {
echo "Installing the rascsi-web.service configuration..."
2021-12-02 17:18:45 -08:00
sudo cp -f " $BASE /src/web/service-infra/rascsi-web.service " " $SYSTEMD_PATH /rascsi-web.service "
sudo sed -i /^ExecStart= /d " $SYSTEMD_PATH /rascsi-web.service "
2021-12-23 09:12:16 -08:00
echo " $TOKEN "
if [ ! -z " $TOKEN " ] ; then
sudo sed -i " 8 i ExecStart= $WEB_INSTALL_PATH /start.sh --password= $TOKEN " " $SYSTEMD_PATH /rascsi-web.service "
sudo chmod 600 " $SYSTEMD_PATH /rascsi-web.service "
2022-01-01 09:38:10 -08:00
echo "Granted access to the Web Interface with the token password that you configured for RaSCSI."
2021-12-23 09:12:16 -08:00
else
sudo sed -i " 8 i ExecStart= $WEB_INSTALL_PATH /start.sh " " $SYSTEMD_PATH /rascsi-web.service "
fi
2021-11-18 18:17:24 -08:00
sudo systemctl daemon-reload
sudo systemctl enable rascsi-web
sudo systemctl start rascsi-web
}
# Stops the rascsi service if it is running
2021-10-20 22:06:00 -07:00
function stopRaScsi( ) {
2021-12-02 17:18:45 -08:00
if [ -f " $SYSTEMD_PATH /rascsi.service " ] ; then
2021-10-20 22:06:00 -07:00
sudo systemctl stop rascsi.service
fi
}
2021-11-18 18:17:24 -08:00
# Stops the rascsi-web service if it is running
2021-10-20 22:06:00 -07:00
function stopRaScsiWeb( ) {
2021-12-02 17:18:45 -08:00
if [ -f " $SYSTEMD_PATH /rascsi-web.service " ] ; then
2021-10-20 22:06:00 -07:00
sudo systemctl stop rascsi-web.service
fi
}
2021-11-18 18:17:24 -08:00
# Stops the monitor_rascsi service if it is running
2021-10-20 22:06:00 -07:00
function stopRaScsiScreen( ) {
2021-12-02 17:18:45 -08:00
if [ -f " $SYSTEMD_PATH /monitor_rascsi.service " ] ; then
2021-10-20 22:06:00 -07:00
sudo systemctl stop monitor_rascsi.service
fi
}
2021-12-06 18:41:46 -08:00
# Stops the macproxy service if it is running
function stopMacproxy( ) {
if [ -f " $SYSTEMD_PATH /macproxy.service " ] ; then
sudo systemctl stop macproxy.service
fi
}
2021-11-18 18:17:24 -08:00
# Starts the monitor_rascsi service if installed
2021-10-20 22:06:00 -07:00
function startRaScsiScreen( ) {
2021-12-02 17:18:45 -08:00
if [ -f " $SYSTEMD_PATH /monitor_rascsi.service " ] ; then
2021-10-20 22:06:00 -07:00
sudo systemctl start monitor_rascsi.service
2021-11-18 18:17:24 -08:00
showRaScsiScreenStatus
2021-10-20 22:06:00 -07:00
fi
}
2021-12-06 18:41:46 -08:00
# Starts the macproxy service if installed
function startMacproxy( ) {
if [ -f " $SYSTEMD_PATH /macproxy.service " ] ; then
sudo systemctl start macproxy.service
showMacproxyStatus
fi
}
2021-11-18 18:17:24 -08:00
# Shows status for the rascsi service
2020-10-26 10:55:53 +11:00
function showRaScsiStatus( ) {
2021-11-14 11:57:38 -08:00
systemctl status rascsi | tee
2020-10-26 10:55:53 +11:00
}
2021-11-18 18:17:24 -08:00
# Shows status for the rascsi-web service
2021-09-14 19:51:12 -07:00
function showRaScsiWebStatus( ) {
2021-11-14 11:57:38 -08:00
systemctl status rascsi-web | tee
2021-09-14 19:51:12 -07:00
}
2021-11-18 18:17:24 -08:00
# Shows status for the monitor_rascsi service
2021-10-19 20:16:11 -07:00
function showRaScsiScreenStatus( ) {
2021-11-14 11:57:38 -08:00
systemctl status monitor_rascsi | tee
2021-10-19 20:16:11 -07:00
}
2021-12-06 18:41:46 -08:00
# Shows status for the macproxy service
function showMacproxyStatus( ) {
systemctl status macproxy | tee
}
2021-11-18 18:17:24 -08:00
# Creates a drive image file with specific parameters
2020-10-26 10:55:53 +11:00
function createDrive600MB( ) {
2020-11-08 11:10:09 +11:00
createDrive 600 "HD600"
2020-10-26 10:55:53 +11:00
}
2021-11-18 18:17:24 -08:00
# Creates a drive image file and prompts for parameters
2020-10-26 10:55:53 +11:00
function createDriveCustom( ) {
driveSize = -1
until [ $driveSize -ge "10" ] && [ $driveSize -le "4000" ] ; do
echo "What drive size would you like (in MB) (10-4000)"
read driveSize
2020-11-08 11:10:09 +11:00
echo "How would you like to name that drive?"
read driveName
2020-10-26 10:55:53 +11:00
done
2021-07-31 10:52:09 -05:00
createDrive " $driveSize " " $driveName "
2020-11-08 11:10:09 +11:00
}
2021-11-18 18:17:24 -08:00
# Creates an HFS file system
2020-11-08 11:10:09 +11:00
function formatDrive( ) {
diskPath = " $1 "
volumeName = " $2 "
if [ ! -x $HFS_FORMAT ] ; then
# Install hfsutils to have hformat to format HFS
2021-10-13 18:01:13 -07:00
sudo apt-get install hfsutils --assume-yes </dev/null
2020-11-08 11:10:09 +11:00
fi
if [ ! -x $HFDISK_BIN ] ; then
# Clone, compile and install 'hfdisk', partition tool
git clone git://www.codesrc.com/git/hfdisk.git
2021-10-07 19:00:49 -06:00
cd hfdisk || exit 1
2020-11-08 11:10:09 +11:00
make
2021-07-31 10:52:09 -05:00
2020-11-08 11:10:09 +11:00
sudo cp hfdisk /usr/bin/hfdisk
fi
# Inject hfdisk commands to create Drive with correct partitions
2021-09-14 19:51:12 -07:00
# https://www.codesrc.com/mediawiki/index.php/HFSFromScratch
# i initialize partition map
# continue with default first block
# C Create 1st partition with type specified next)
# continue with default
# 32 32 blocks (required for HFS+)
# Driver_Partition Partition Name
# Apple_Driver Partition Type (available types: Apple_Driver, Apple_Driver43, Apple_Free, Apple_HFS...)
# C Create 2nd partition with type specified next
# continue with default first block
# continue with default block size (rest of the disk)
# ${volumeName} Partition name provided by user
# Apple_HFS Partition Type
# w Write partition map to disk
# y Confirm partition table
# p Print partition map
2021-07-31 10:52:09 -05:00
( echo i; echo ; echo C; echo ; echo 32; echo "Driver_Partition" ; echo "Apple_Driver" ; echo C; echo ; echo ; echo " ${ volumeName } " ; echo "Apple_HFS" ; echo w; echo y; echo p; ) | $HFDISK_BIN " $diskPath "
2020-11-08 11:10:09 +11:00
partitionOk = $?
if [ $partitionOk -eq 0 ] ; then
2021-10-13 18:01:13 -07:00
if [ ! -f " $LIDO_DRIVER " ] ; then
2021-07-31 10:52:09 -05:00
echo "Lido driver couldn't be found. Make sure RaSCSI is up-to-date with git pull"
2020-11-08 11:10:09 +11:00
return 1
fi
# Burn Lido driver to the disk
2021-10-13 18:01:13 -07:00
dd if = " $LIDO_DRIVER " of = " $diskPath " seek = 64 count = 32 bs = 512 conv = notrunc
2020-11-08 11:10:09 +11:00
driverInstalled = $?
if [ $driverInstalled -eq 0 ] ; then
# Format the partition with HFS file system
$HFS_FORMAT -l " ${ volumeName } " " $diskPath " 1
hfsFormattedOk = $?
if [ $hfsFormattedOk -eq 0 ] ; then
echo "Disk created with success."
else
echo "Unable to format HFS partition."
return 4
fi
else
echo "Unable to install Lido Driver."
return 3
fi
else
echo "Unable to create the partition."
return 2
fi
2020-10-26 10:55:53 +11:00
}
2021-11-18 18:17:24 -08:00
# Creates an image file
2020-10-26 10:55:53 +11:00
function createDrive( ) {
2020-11-08 11:10:09 +11:00
if [ $# -ne 2 ] ; then
echo "To create a Drive, volume size and volume name must be provided"
echo " $ createDrive 600 \"RaSCSI Drive\" "
echo "Drive wasn't created."
return
fi
2020-10-26 10:55:53 +11:00
driveSize = $1
2020-11-08 11:10:09 +11:00
driveName = $2
2021-10-07 19:00:49 -06:00
mkdir -p " $VIRTUAL_DRIVER_PATH "
2021-12-08 15:59:17 -08:00
drivePath = " ${ VIRTUAL_DRIVER_PATH } / ${ driveSize } MB.hda "
2021-07-31 10:52:09 -05:00
2021-10-07 19:00:49 -06:00
if [ ! -f " $drivePath " ] ; then
2020-10-26 10:55:53 +11:00
echo " Creating a ${ driveSize } MB Drive "
2021-10-07 19:00:49 -06:00
truncate --size " ${ driveSize } m " " $drivePath "
2020-11-08 11:10:09 +11:00
echo "Formatting drive with HFS"
formatDrive " $drivePath " " $driveName "
2020-10-26 10:55:53 +11:00
else
echo "Error: drive already exists"
fi
}
2021-11-18 18:17:24 -08:00
# Modifies system configurations for a wired network bridge
2021-09-14 19:51:12 -07:00
function setupWiredNetworking( ) {
echo "Setting up wired network..."
LAN_INTERFACE = eth0
echo " $LAN_INTERFACE will be configured for network forwarding with DHCP. "
echo ""
echo "WARNING: If you continue, the IP address of your Pi may change upon reboot."
echo "Please make sure you will not lose access to the Pi system."
echo ""
2021-12-23 09:12:16 -08:00
echo "Do you want to proceed with network configuration using the default settings? [Y/n]"
2021-09-14 19:51:12 -07:00
read REPLY
if [ " $REPLY " = = "N" ] || [ " $REPLY " = = "n" ] ; then
echo "Available wired interfaces on this system:"
2021-12-23 09:12:16 -08:00
echo ` ip -o addr show scope link | awk '{split($0, a); print $2}' | grep eth`
2021-09-14 19:51:12 -07:00
echo "Please type the wired interface you want to use and press Enter:"
2021-10-13 18:01:13 -07:00
read SELECTED
2021-09-14 19:51:12 -07:00
LAN_INTERFACE = $SELECTED
fi
2021-10-07 19:00:49 -06:00
if [ " $( grep -c "^denyinterfaces" /etc/dhcpcd.conf) " -ge 1 ] ; then
2021-09-14 19:51:12 -07:00
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
2021-10-19 20:16:11 -07:00
sudo sed -i /^denyinterfaces/d /etc/dhcpcd.conf
2021-09-14 19:51:12 -07:00
fi
2021-10-13 18:01:13 -07:00
sudo bash -c 'echo "denyinterfaces ' $LAN_INTERFACE '" >> /etc/dhcpcd.conf'
2021-09-14 19:51:12 -07:00
echo "Modified /etc/dhcpcd.conf"
# default config file is made for eth0, this will set the right net interface
2021-10-07 19:00:49 -06:00
sudo bash -c 'sed s/eth0/' " $LAN_INTERFACE " '/g ' " $BASE " '/src/raspberrypi/os_integration/rascsi_bridge > /etc/network/interfaces.d/rascsi_bridge'
2021-09-14 19:51:12 -07:00
echo "Modified /etc/network/interfaces.d/rascsi_bridge"
echo "Configuration completed!"
2021-10-17 18:31:17 -07:00
echo "Please make sure you attach a DaynaPORT network adapter to your RaSCSI configuration."
echo "Either use the Web UI, or do this on the command line (assuming SCSI ID 6):"
echo " rasctl -i 6 -c attach -t scdp -f $LAN_INTERFACE "
2021-09-14 19:51:12 -07:00
echo ""
echo "We need to reboot your Pi"
echo "Press Enter to reboot or CTRL-C to exit"
read
echo "Rebooting..."
sleep 3
sudo reboot
}
2021-11-18 18:17:24 -08:00
# Modifies system configurations for a wireless network bridge with NAT
2021-09-14 19:51:12 -07:00
function setupWirelessNetworking( ) {
NETWORK = "10.10.20"
IP = $NETWORK .2 # Macintosh or Device IP
NETWORK_MASK = "255.255.255.0"
CIDR = "24"
ROUTER_IP = $NETWORK .1
ROUTING_ADDRESS = $NETWORK .0/$CIDR
WLAN_INTERFACE = "wlan0"
echo " $WLAN_INTERFACE will be configured for network forwarding with static IP assignment. "
echo "Configure your Macintosh or other device with the following:"
echo " IP Address (static): $IP "
echo " Router Address: $ROUTER_IP "
echo " Subnet Mask: $NETWORK_MASK "
echo "DNS Server: Any public DNS server"
echo ""
2021-12-23 09:12:16 -08:00
echo "Do you want to proceed with network configuration using the default settings? [Y/n]"
2021-09-14 19:51:12 -07:00
read REPLY
if [ " $REPLY " = = "N" ] || [ " $REPLY " = = "n" ] ; then
echo "Available wireless interfaces on this system:"
2021-12-23 09:12:16 -08:00
echo ` ip -o addr show scope link | awk '{split($0, a); print $2}' | grep wlan`
2021-09-14 19:51:12 -07:00
echo "Please type the wireless interface you want to use and press Enter:"
read -r WLAN_INTERFACE
echo "Base IP address (ex. 10.10.20):"
read -r NETWORK
echo "CIDR for Subnet Mask (ex. '24' for 255.255.255.0):"
read -r CIDR
ROUTER_IP = $NETWORK .1
ROUTING_ADDRESS = $NETWORK .0/$CIDR
fi
2021-10-07 19:00:49 -06:00
if [ " $( grep -c "^net.ipv4.ip_forward=1" /etc/sysctl.conf) " -ge 1 ] ; then
2021-09-14 19:51:12 -07:00
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
else
sudo bash -c 'echo "net.ipv4.ip_forward=1" >> /etc/sysctl.conf'
2021-12-23 09:12:16 -08:00
echo "Modified /etc/sysctl.conf"
2021-09-14 19:51:12 -07:00
fi
2021-12-04 11:07:17 -08:00
# Check if iptables is installed
if [ ` apt-cache policy iptables | grep Installed | grep -c "(none)" ` -eq 0 ] ; then
echo "iptables is already installed"
else
sudo apt-get install iptables --assume-yes </dev/null
fi
2021-09-14 19:51:12 -07:00
sudo iptables --flush
sudo iptables -t nat -F
sudo iptables -X
sudo iptables -Z
sudo iptables -P INPUT ACCEPT
sudo iptables -P OUTPUT ACCEPT
sudo iptables -P FORWARD ACCEPT
2021-10-07 19:00:49 -06:00
sudo iptables -t nat -A POSTROUTING -o " $WLAN_INTERFACE " -s " $ROUTING_ADDRESS " -j MASQUERADE
2021-09-14 19:51:12 -07:00
# Check if iptables-persistent is installed
2021-10-13 18:01:13 -07:00
if [ ` apt-cache policy iptables-persistent | grep Installed | grep -c "(none)" ` -eq 0 ] ; then
echo "iptables-persistent is already installed"
2021-09-14 19:51:12 -07:00
sudo iptables-save --file /etc/iptables/rules.v4
2021-10-13 18:01:13 -07:00
else
sudo apt-get install iptables-persistent --assume-yes </dev/null
2021-09-14 19:51:12 -07:00
fi
echo "Modified /etc/iptables/rules.v4"
echo "Configuration completed!"
echo ""
2021-10-17 18:31:17 -07:00
echo "Please make sure you attach a DaynaPORT network adapter to your RaSCSI configuration"
echo "Either use the Web UI, or do this on the command line (assuming SCSI ID 6):"
echo " rasctl -i 6 -c attach -t scdp -f $WLAN_INTERFACE : $ROUTER_IP / $CIDR "
2021-09-14 19:51:12 -07:00
echo ""
echo "We need to reboot your Pi"
echo "Press Enter to reboot or CTRL-C to exit"
read REPLY
echo "Rebooting..."
sleep 3
sudo reboot
}
2021-11-18 18:17:24 -08:00
# Downloads, compiles, and installs Netatalk (AppleShare server)
2021-10-17 18:31:17 -07:00
function installNetatalk( ) {
NETATALK_VERSION = "20200806"
AFP_SHARE_PATH = " $HOME /afpshare "
echo "Cleaning up existing Netatalk installation, if it exists..."
sudo /etc/init.d/netatalk stop || true
sudo rm -rf /etc/default/netatalk.conf /etc/netatalk || true
if [ -f " $HOME /netatalk-classic- $NETATALK_VERSION " ] ; then
echo " Deleting existing version of $HOME /netatalk-classic- $NETATALK_VERSION . "
sudo rm -rf " $HOME /netatalk-classic- $NETATALK_VERSION "
fi
echo " Downloading netatalk-classic- $NETATALK_VERSION to $HOME "
cd $HOME || exit 1
2021-11-02 18:22:36 -07:00
wget -O " $NETATALK_VERSION .tar.gz " " https://github.com/christopherkobayashi/netatalk-classic/archive/refs/tags/ $NETATALK_VERSION .tar.gz " </dev/null
2021-10-17 18:31:17 -07:00
tar -xzvf $NETATALK_VERSION .tar.gz
cd " netatalk-classic- $NETATALK_VERSION " || exit 1
sed -i /^~/d ./config/AppleVolumes.default.tmpl
2021-11-08 18:33:33 -08:00
echo " $AFP_SHARE_PATH \"Pi File Server\" adouble:v1 volcharset:ASCII " >> ./config/AppleVolumes.default.tmpl
2021-10-17 18:31:17 -07:00
echo "ATALKD_RUN=yes" >> ./config/netatalk.conf
echo "\"RaSCSI-Pi\" -transall -uamlist uams_guest.so,uams_clrtxt.so,uams_dhx.so -defaultvol /etc/netatalk/AppleVolumes.default -systemvol /etc/netatalk/AppleVolumes.system -nosavepassword -nouservol -guestname \"nobody\" -setuplog \"default log_maxdebug /var/log/afpd.log\"" >> ./config/afpd.conf.tmpl
( sudo apt-get update && sudo apt-get install libssl-dev libdb-dev libcups2-dev autotools-dev automake libtool --assume-yes ) </dev/null
echo "Compiling and installing Netatalk..."
./bootstrap
./configure --enable-debian --enable-cups --sysconfdir= /etc --with-uams-path= /usr/lib/netatalk
( make && sudo make install ) </dev/null
if [ -d " $AFP_SHARE_PATH " ] ; then
echo " The $AFP_SHARE_PATH directory already exists. "
else
echo " The $AFP_SHARE_PATH directory does not exist; creating... "
mkdir -p " $AFP_SHARE_PATH "
chmod -R 2775 " $AFP_SHARE_PATH "
fi
if [ [ ` grep -c netatalk /etc/rc.local` -eq 0 ] ] ; then
sudo sed -i "/^exit 0/i sudo /etc/init.d/netatalk start" /etc/rc.local
echo "Modified /etc/rc.local"
fi
sudo /etc/init.d/netatalk start
if [ [ ` lsmod | grep -c appletalk` -eq 0 ] ] ; then
echo ""
echo "Your system may not have support for AppleTalk networking."
echo "Use TCP to connect to your AppleShare server via the IP address of the network interface that is connected to the rest of your network:"
echo ` ip -4 addr show scope global | grep -oP '(?<=inet\s)\d+(\.\d+){3}' `
echo "See wiki for information on how to compile support for AppleTalk into your Linux kernel."
fi
echo ""
echo "Netatalk is now installed and configured to run on system boot."
echo "To start or stop the File Server manually, do:"
echo "sudo /etc/init.d/netatalk start"
echo "sudo /etc/init.d/netatalk stop"
echo ""
echo "Make sure that the user running Netatalk has a password of 8 chars or less. You may execute the 'passwd' command to change the password of the current user."
echo "For more information on configuring Netatalk and accessing AppleShare from your vintage Macs, see wiki:"
echo "https://github.com/akuker/RASCSI/wiki/AFP-File-Sharing"
echo ""
}
2021-11-18 18:17:24 -08:00
# Downloads, compiles, and installs Macproxy (web proxy)
2021-11-08 18:58:30 -08:00
function installMacproxy {
2021-11-13 17:45:40 -08:00
PORT = 5000
echo "Macproxy is a Web Proxy for all vintage Web Browsers -- not only for Macs!"
echo ""
echo " By default, Macproxy listens to port $PORT , but you can choose any other available port. "
echo -n "Enter a port number 1024 - 65535, or press Enter to use the default port: "
read -r CHOICE
if [ $CHOICE -ge "1024" ] && [ $CHOICE -le "65535" ] ; then
PORT = $CHOICE
else
echo " Using the default port $PORT "
fi
2021-11-18 18:17:24 -08:00
( sudo apt-get update && sudo apt-get install python3 python3-venv --assume-yes ) </dev/null
2021-12-31 20:07:17 -08:00
MACPROXY_VER = "21.12.3"
2021-12-02 17:18:45 -08:00
MACPROXY_PATH = " $HOME /macproxy- $MACPROXY_VER "
if [ -d " $MACPROXY_PATH " ] ; then
echo " The $MACPROXY_PATH directory already exists. Delete it to proceed with the installation. "
2021-11-08 18:58:30 -08:00
exit 1
fi
cd " $HOME " || exit 1
2021-12-06 18:41:46 -08:00
wget -O " macproxy- $MACPROXY_VER .tar.gz " " https://github.com/rdmark/macproxy/archive/refs/tags/ $MACPROXY_VER .tar.gz " </dev/null
2021-11-13 17:45:40 -08:00
tar -xzvf " macproxy- $MACPROXY_VER .tar.gz "
2021-12-06 18:41:46 -08:00
stopMacproxy
2021-12-02 17:18:45 -08:00
sudo cp " $MACPROXY_PATH /macproxy.service " " $SYSTEMD_PATH "
sudo sed -i /^ExecStart= /d " $SYSTEMD_PATH /macproxy.service "
2021-12-06 18:41:46 -08:00
sudo sed -i " 8 i ExecStart= $MACPROXY_PATH /start_macproxy.sh " " $SYSTEMD_PATH /macproxy.service "
2021-11-08 18:58:30 -08:00
sudo systemctl daemon-reload
sudo systemctl enable macproxy
2021-12-06 18:41:46 -08:00
startMacproxy
2021-11-08 18:58:30 -08:00
2021-11-13 17:45:40 -08:00
echo -n "Macproxy is now running on IP "
echo -n ` ip -4 addr show scope global | grep -oP '(?<=inet\s)\d+(\.\d+){3}' `
echo " port $PORT "
echo "Configure your browser to use the above as http (and https) proxy."
2021-11-08 18:58:30 -08:00
echo ""
}
2021-11-18 18:17:24 -08:00
# Prints a notification if the rascsi.service file was backed up
2021-09-28 10:56:14 -07:00
function notifyBackup {
2021-12-02 17:18:45 -08:00
if " $SYSTEMD_BACKUP " ; then
2021-09-28 10:56:14 -07:00
echo ""
2021-12-02 17:18:45 -08:00
echo " IMPORTANT: $SYSTEMD_PATH /rascsi.service has been overwritten. "
2021-09-28 10:56:14 -07:00
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
}
2021-11-26 20:41:10 -08:00
# Creates the group and modifies current user for Web Interface auth
function enableWebInterfaceAuth {
AUTH_GROUP = "rascsi"
if [ $( getent group " $AUTH_GROUP " ) ] ; then
echo " The ' $AUTH_GROUP ' group already exists. "
else
echo " Creating the ' $AUTH_GROUP ' group. "
sudo groupadd " $AUTH_GROUP "
fi
echo " Adding user ' $USER ' to the ' $AUTH_GROUP ' group. "
sudo usermod -a -G " $AUTH_GROUP " " $USER "
}
2021-11-18 18:17:24 -08:00
# Executes the keyword driven scripts for a particular action in the main menu
2021-07-31 10:52:09 -05:00
function runChoice( ) {
case $1 in
1)
2021-11-18 18:17:24 -08:00
echo " Installing / Updating RaSCSI Service ( ${ CONNECT_TYPE :- FULLSPEC } ) + Web Interface "
echo "This script will make the following changes to your system:"
echo "- Install additional packages with apt-get"
echo "- Add and modify systemd services"
2021-12-02 17:18:45 -08:00
echo "- Modify and enable Apache2 and Nginx web services"
2022-01-01 09:38:10 -08:00
echo "- Create files and directories"
echo "- Change permissions of files and directories"
2021-11-18 18:17:24 -08:00
echo "- Modify user groups and permissions"
echo "- Install binaries to /usr/local/bin"
echo "- Install manpages to /usr/local/man"
sudoCheck
2022-01-01 09:38:10 -08:00
configureTokenAuth
2021-09-14 19:51:12 -07:00
stopOldWebInterface
updateRaScsiGit
createImagesDir
2021-11-18 18:17:24 -08:00
createCfgDir
2021-09-14 19:51:12 -07:00
installPackages
2021-11-18 18:17:24 -08:00
stopRaScsiScreen
stopRaScsi
compileRaScsi
2021-12-02 17:18:45 -08:00
backupRaScsiService
2021-07-31 10:52:09 -05:00
installRaScsi
2021-11-18 18:17:24 -08:00
enableRaScsiService
2022-01-01 09:38:10 -08:00
if [ -f " $SYSTEMD_PATH /monitor_rascsi.service " ] ; then
echo "Detected monitor_rascsi.service; will run the installation steps for the OLED monitor."
installRaScsiScreen
fi
2021-09-14 19:51:12 -07:00
installRaScsiWebInterface
2021-11-18 18:17:24 -08:00
installWebInterfaceService
2022-01-01 09:38:10 -08:00
showRaScsiScreenStatus
2021-07-31 10:52:09 -05:00
showRaScsiStatus
2021-09-14 19:51:12 -07:00
showRaScsiWebStatus
2021-09-28 10:56:14 -07:00
notifyBackup
2021-11-18 18:17:24 -08:00
echo " Installing / Updating RaSCSI Service ( ${ CONNECT_TYPE :- FULLSPEC } ) + Web Interface - Complete! "
2021-07-31 10:52:09 -05:00
; ;
2)
2021-11-18 18:17:24 -08:00
echo " Installing / Updating RaSCSI Service ( ${ CONNECT_TYPE :- FULLSPEC } ) "
echo "This script will make the following changes to your system:"
echo "- Install additional packages with apt-get"
echo "- Add and modify systemd services"
2022-01-01 09:38:10 -08:00
echo "- Create files ans directories"
echo "- Change permissions of files and directories"
2021-11-18 18:17:24 -08:00
echo "- Modify user groups and permissions"
echo "- Install binaries to /usr/local/bin"
echo "- Install manpages to /usr/local/man"
sudoCheck
2022-01-01 09:38:10 -08:00
configureTokenAuth
2021-09-14 19:51:12 -07:00
updateRaScsiGit
createImagesDir
installPackages
2021-11-18 18:17:24 -08:00
stopRaScsiScreen
stopRaScsi
compileRaScsi
2021-12-02 17:18:45 -08:00
backupRaScsiService
2021-09-14 19:51:12 -07:00
installRaScsi
2021-11-18 18:17:24 -08:00
enableRaScsiService
2022-01-01 09:38:10 -08:00
if [ -f " $SYSTEMD_PATH /monitor_rascsi.service " ] ; then
echo "Detected monitor_rascsi.service; will run the installation steps for the OLED monitor."
installRaScsiScreen
fi
showRaScsiScreenStatus
2021-07-31 10:52:09 -05:00
showRaScsiStatus
2021-09-28 10:56:14 -07:00
notifyBackup
2021-11-18 18:17:24 -08:00
echo " Installing / Updating RaSCSI Service ( ${ CONNECT_TYPE :- FULLSPEC } ) - Complete! "
2021-10-19 20:16:11 -07:00
; ;
2021-09-14 19:51:12 -07:00
3)
2021-10-19 20:16:11 -07:00
echo "Installing / Updating RaSCSI OLED Screen"
2021-11-18 18:17:24 -08:00
echo "This script will make the following changes to your system:"
echo "- Install additional packages with apt-get"
echo "- Add and modify systemd services"
echo "- Modify the Raspberry Pi boot configuration (may require a reboot)"
sudoCheck
2021-10-19 20:16:11 -07:00
installRaScsiScreen
showRaScsiScreenStatus
echo "Installing / Updating RaSCSI OLED Screen - Complete!"
; ;
4)
2021-12-08 15:59:17 -08:00
echo "Creating an HFS formatted 600MB drive image with LIDO driver"
2021-09-14 19:51:12 -07:00
createDrive600MB
2021-12-08 15:59:17 -08:00
echo "Creating an HFS formatted 600MB drive image with LIDO driver - Complete!"
2021-07-31 10:52:09 -05:00
; ;
2021-10-19 20:16:11 -07:00
5)
2021-12-08 15:59:17 -08:00
echo "Creating an HFS formatted drive image with LIDO driver"
2021-09-14 19:51:12 -07:00
createDriveCustom
2021-12-08 15:59:17 -08:00
echo "Creating an HFS formatted drive image with LIDO driver - Complete!"
2021-07-31 10:52:09 -05:00
; ;
2021-10-19 20:16:11 -07:00
6)
2021-09-14 19:51:12 -07:00
echo "Configuring wired network bridge"
2021-11-18 18:17:24 -08:00
echo "This script will make the following changes to your system:"
echo "- Create a virtual network bridge interface in /etc/network/interfaces.d"
echo "- Modify /etc/dhcpcd.conf to bridge the Ethernet interface (may change the IP address; requires a reboot)"
sudoCheck
2021-09-14 19:51:12 -07:00
showMacNetworkWired
2021-11-18 18:17:24 -08:00
setupWiredNetworking
2021-09-14 19:51:12 -07:00
echo "Configuring wired network bridge - Complete!"
2021-07-31 10:52:09 -05:00
; ;
2021-10-19 20:16:11 -07:00
7)
2021-09-14 19:51:12 -07:00
echo "Configuring wifi network bridge"
2021-11-18 18:17:24 -08:00
echo "This script will make the following changes to your system:"
echo "- Install additional packages with apt-get"
echo "- Modify /etc/sysctl.conf to enable IPv4 forwarding"
echo "- Add NAT rules for the wlan interface (requires a reboot)"
sudoCheck
showMacNetworkWireless
2021-09-14 19:51:12 -07:00
setupWirelessNetworking
echo "Configuring wifi network bridge - Complete!"
2021-07-31 10:52:09 -05:00
; ;
2021-10-19 20:16:11 -07:00
8)
2021-10-17 18:31:17 -07:00
echo "Installing AppleShare File Server"
2021-11-18 18:17:24 -08:00
echo "This script will make the following changes to your system:"
echo "- Install additional packages with apt-get"
echo "- Create directories and change permissions"
echo "- Install binaries to /usr/local/sbin"
echo "- Install manpages to /usr/local/share/man/"
echo "- Install configuration files to /etc"
echo "- Modify /etc/rc.local to start Netatalk daemons on system startup"
echo ""
sudoCheck
2021-10-17 18:31:17 -07:00
installNetatalk
echo "Installing AppleShare File Server - Complete!"
; ;
2021-11-08 18:58:30 -08:00
9)
echo "Installing Web Proxy Server"
2021-11-18 18:17:24 -08:00
echo "This script will make the following changes to your system:"
echo "- Install additional packages with apt-get"
echo "- Add and modify systemd services"
sudoCheck
2021-11-08 18:58:30 -08:00
installMacproxy
echo "Installing Web Proxy Server - Complete!"
; ;
2021-11-18 18:17:24 -08:00
10)
echo " Configuring RaSCSI stand-alone ( ${ CONNECT_TYPE :- FULLSPEC } ) "
echo "This script will make the following changes to your system:"
echo "- Install additional packages with apt-get"
echo "- Create directories and change permissions"
echo "- Install binaries to /usr/local/bin"
echo "- Install manpages to /usr/local/man"
sudoCheck
updateRaScsiGit
createImagesDir
installPackages
stopRaScsi
compileRaScsi
installRaScsi
echo " Configuring RaSCSI stand-alone ( ${ CONNECT_TYPE :- FULLSPEC } ) - Complete! "
echo "Use 'rascsi' to launch RaSCSI, and 'rasctl' to control the running process."
; ;
11)
echo "Configuring RaSCSI Web Interface stand-alone"
echo "This script will make the following changes to your system:"
echo "- Install additional packages with apt-get"
echo "- Add and modify systemd services"
echo "- Modify and enable Apache2 and Nginx web service"
echo "- Create directories and change permissions"
echo "- Modify user groups and permissions"
sudoCheck
updateRaScsiGit
createCfgDir
installPackages
installRaScsiWebInterface
echo "Configuring RaSCSI Web Interface stand-alone - Complete!"
echo "Launch the Web Interface with the 'start.sh' script. To use a custom port for the web server: 'start.sh --port=8081"
; ;
2021-11-26 20:41:10 -08:00
12)
echo "Enabling authentication for the RaSCSI Web Interface"
echo "This script will make the following changes to your system:"
echo "- Modify users and user groups"
sudoCheck
enableWebInterfaceAuth
echo "Enabling authentication for the RaSCSI Web Interface - Complete!"
echo " Use the credentials for user ' $USER ' to log in to the Web Interface. "
; ;
2021-07-31 10:52:09 -05:00
-h| --help| h| help )
showMenu
; ;
*)
echo " ${ 1 } is not a valid option, exiting... "
exit 1
esac
}
2021-11-18 18:17:24 -08:00
# Reads and validates the main menu choice
2021-07-31 10:52:09 -05:00
function readChoice( ) {
choice = -1
2021-11-26 20:41:10 -08:00
until [ $choice -ge "0" ] && [ $choice -le "12" ] ; do
2021-11-26 22:49:45 -06:00
echo -n "Enter your choice (0-12) or CTRL-C to exit: "
2021-07-31 10:52:09 -05:00
read -r choice
done
runChoice " $choice "
}
2021-11-18 18:17:24 -08:00
# Shows the interactive main menu of the script
2020-11-08 11:10:09 +11:00
function showMenu( ) {
echo ""
echo "Choose among the following options:"
2021-09-14 19:51:12 -07:00
echo " INSTALL/UPDATE RASCSI ( ${ CONNECT_TYPE -FULLSPEC } version) "
2021-09-19 14:29:01 -07:00
echo " 1) install or update RaSCSI Service + Web Interface"
2021-09-14 19:51:12 -07:00
echo " 2) install or update RaSCSI Service"
2021-10-19 20:16:11 -07:00
echo " 3) install or update RaSCSI OLED Screen (requires hardware)"
2021-09-19 14:29:01 -07:00
echo "CREATE HFS FORMATTED (MAC) IMAGE WITH LIDO DRIVERS"
echo "** For the Mac Plus, it's better to create an image through the Web Interface **"
2021-10-19 20:16:11 -07:00
echo " 4) 600MB drive (suggested size)"
echo " 5) custom drive size (up to 4000MB)"
2021-11-08 18:58:30 -08:00
echo "NETWORK BRIDGE ASSISTANT"
echo " 6) configure network bridge for Ethernet (DHCP)"
echo " 7) configure network bridge for WiFi (static IP + NAT)"
echo "INSTALL COMPANION APPS"
echo " 8) install AppleShare File Server (Netatalk)"
2021-11-13 17:45:40 -08:00
echo " 9) install Web Proxy Server (Macproxy)"
2021-11-18 18:17:24 -08:00
echo "ADVANCED OPTIONS"
echo " 10) compile and install RaSCSI stand-alone"
echo " 11) configure the RaSCSI Web Interface stand-alone"
2021-11-26 20:41:10 -08:00
echo " 12) enable authentication for the RaSCSI Web Interface"
2020-11-08 11:10:09 +11:00
}
2020-10-26 10:55:53 +11:00
2021-11-18 18:17:24 -08:00
# parse arguments passed to the script
2021-09-14 19:51:12 -07:00
while [ " $1 " != "" ] ; do
2021-10-07 19:00:49 -06:00
PARAM = $( echo " $1 " | awk -F= '{print $1}' )
VALUE = $( echo " $1 " | awk -F= '{print $2}' )
2021-09-14 19:51:12 -07:00
case $PARAM in
-c | --connect_type)
CONNECT_TYPE = $VALUE
; ;
2021-11-14 01:42:34 -08:00
-r | --run_choice)
RUN_CHOICE = $VALUE
; ;
-j | --cores)
CORES = $VALUE
; ;
2021-09-14 19:51:12 -07:00
*)
echo " ERROR: unknown parameter \" $PARAM \" "
exit 1
; ;
esac
case $VALUE in
2021-11-26 20:41:10 -08:00
FULLSPEC | STANDARD | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12)
2021-09-14 19:51:12 -07:00
; ;
*)
echo " ERROR: unknown option \" $VALUE \" "
2021-12-23 09:12:16 -08:00
exit 1
2021-09-14 19:51:12 -07:00
; ;
esac
shift
done
2020-10-26 10:55:53 +11:00
2020-11-08 11:10:09 +11:00
showRaSCSILogo
2021-11-14 11:57:38 -08:00
initialChecks
2021-09-14 19:51:12 -07:00
if [ -z " ${ RUN_CHOICE } " ] ; then # RUN_CHOICE is unset, show menu
2021-07-31 10:52:09 -05:00
showMenu
readChoice
else
2021-09-14 19:51:12 -07:00
runChoice " $RUN_CHOICE "
2021-07-31 10:52:09 -05:00
fi