Introduce FTP server option; sundry bug fixes (#1028)

* Add script to install ftp server

* Grep only the first ip address to avoid capturing the docker ip address

* Consistently use --assume-yes and --no-install-recommends with apt-get

* Capture corner case where both rascsi and piscsi groups exist

* Add CI/CD dependency of easyinstall.sh

* Update the run choices
This commit is contained in:
Daniel Markstedt 2022-12-09 21:00:31 -08:00 committed by GitHub
parent ce6bc79b2c
commit 2354b62f43
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 35 deletions

View File

@ -7,6 +7,7 @@ on:
- 'python/web/**' - 'python/web/**'
- 'python/common/**' - 'python/common/**'
- '.github/workflows/web.yml' - '.github/workflows/web.yml'
- 'easyinstall.sh'
jobs: jobs:
backend_checks: backend_checks:

View File

@ -12,7 +12,7 @@ WORKDIR /home/pi/piscsi
COPY --chown=pi:pi easyinstall.sh . COPY --chown=pi:pi easyinstall.sh .
COPY --chown=pi:pi cpp cpp COPY --chown=pi:pi cpp cpp
COPY --chown=pi:pi doc doc COPY --chown=pi:pi doc doc
RUN ./easyinstall.sh --run_choice=15 --cores=`nproc` RUN ./easyinstall.sh --run_choice=16 --cores=`nproc`
FROM debian:bullseye-slim AS runner FROM debian:bullseye-slim AS runner
USER root USER root

View File

@ -32,14 +32,14 @@ COPY --chown=pi:pi python/web python/web
COPY --chown=pi:pi python/common python/common COPY --chown=pi:pi python/common python/common
# Install standalone PiSCSI Web UI # Install standalone PiSCSI Web UI
RUN ./easyinstall.sh --run_choice=11 \ RUN ./easyinstall.sh --run_choice=12 \
&& sudo apt-get remove build-essential --yes \ && sudo apt-get remove build-essential --yes \
&& sudo apt autoremove -y \ && sudo apt autoremove -y \
&& sudo apt-get clean \ && sudo apt-get clean \
&& sudo rm -rf /var/lib/apt/lists/* && sudo rm -rf /var/lib/apt/lists/*
# Enable web UI authentication # Enable web UI authentication
RUN ./easyinstall.sh --run_choice=13 RUN ./easyinstall.sh --run_choice=14
# Setup wired network bridge # Setup wired network bridge
RUN ./easyinstall.sh --run_choice=5 --headless RUN ./easyinstall.sh --run_choice=5 --headless

View File

@ -67,6 +67,7 @@ HFDISK_BIN=/usr/bin/hfdisk
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}
TOKEN="" TOKEN=""
AUTH_GROUP="piscsi"
SECRET_FILE="$HOME/.config/piscsi/secret" SECRET_FILE="$HOME/.config/piscsi/secret"
FILE_SHARE_PATH="$HOME/shared_files" FILE_SHARE_PATH="$HOME/shared_files"
FILE_SHARE_NAME="Pi File Server" FILE_SHARE_NAME="Pi File Server"
@ -110,7 +111,7 @@ function installPackages() {
echo "Skipping package installation" echo "Skipping package installation"
return 0 return 0
fi fi
sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y -qq \ sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --assume-yes -qq \
$APT_PACKAGES_COMMON \ $APT_PACKAGES_COMMON \
$APT_PACKAGES_BACKEND \ $APT_PACKAGES_BACKEND \
$APT_PACKAGES_PYTHON \ $APT_PACKAGES_PYTHON \
@ -123,7 +124,7 @@ function installPackagesStandalone() {
echo "Skipping package installation" echo "Skipping package installation"
return 0 return 0
fi fi
sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y -qq \ sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --assume-yes -qq \
$APT_PACKAGES_COMMON \ $APT_PACKAGES_COMMON \
$APT_PACKAGES_BACKEND $APT_PACKAGES_BACKEND
} }
@ -134,7 +135,7 @@ function installPackagesWeb() {
echo "Skipping package installation" echo "Skipping package installation"
return 0 return 0
fi fi
sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y -qq \ sudo apt-get update && sudo DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --assume-yes -qq \
$APT_PACKAGES_COMMON \ $APT_PACKAGES_COMMON \
$APT_PACKAGES_PYTHON \ $APT_PACKAGES_PYTHON \
$APT_PACKAGES_WEB $APT_PACKAGES_WEB
@ -422,7 +423,10 @@ function migrateLegacyData() {
sudo cp "$CPP_PATH/os_integration/piscsi_bridge" "/etc/network/interfaces.d" sudo cp "$CPP_PATH/os_integration/piscsi_bridge" "/etc/network/interfaces.d"
echo "Replaced rascsi_bridge with piscsi_bridge" echo "Replaced rascsi_bridge with piscsi_bridge"
fi fi
if [ $(getent group rascsi) ]; then if [[ $(getent group rascsi) && $(getent group "$AUTH_GROUP") ]]; then
sudo groupdel rascsi
echo "Deleted the rascsi group in favor of the existing piscsi group"
elif [ $(getent group rascsi) ]; then
sudo groupmod --new-name piscsi rascsi sudo groupmod --new-name piscsi rascsi
echo "Renamed the rascsi group to piscsi" echo "Renamed the rascsi group to piscsi"
fi fi
@ -667,7 +671,7 @@ function setupWirelessNetworking() {
if [ `apt-cache policy iptables | grep Installed | grep -c "(none)"` -eq 0 ]; then if [ `apt-cache policy iptables | grep Installed | grep -c "(none)"` -eq 0 ]; then
echo "iptables is already installed" echo "iptables is already installed"
else else
sudo apt-get install iptables --assume-yes </dev/null sudo apt-get install iptables --assume-yes --no-install-recommends </dev/null
fi fi
sudo iptables --flush sudo iptables --flush
@ -684,7 +688,7 @@ function setupWirelessNetworking() {
echo "iptables-persistent is already installed" echo "iptables-persistent is already installed"
sudo iptables-save --file /etc/iptables/rules.v4 sudo iptables-save --file /etc/iptables/rules.v4
else else
sudo apt-get install iptables-persistent --assume-yes </dev/null sudo apt-get install iptables-persistent --assume-yes --no-install-recommends </dev/null
fi fi
echo "Modified /etc/iptables/rules.v4" echo "Modified /etc/iptables/rules.v4"
@ -796,7 +800,7 @@ function installMacproxy {
if [[ $SKIP_PACKAGES ]]; then if [[ $SKIP_PACKAGES ]]; then
echo "Skipping package installation" echo "Skipping package installation"
else else
sudo apt-get update && sudo apt-get install python3 python3-venv --assume-yes </dev/null sudo apt-get update && sudo apt-get install python3 python3-venv --assume-yes --no-install-recommends </dev/null
fi fi
MACPROXY_VER="22.8" MACPROXY_VER="22.8"
@ -817,12 +821,26 @@ function installMacproxy {
startMacproxy startMacproxy
echo -n "Macproxy is now running on IP " echo -n "Macproxy is now running on IP "
echo -n `ip -4 addr show scope global | grep -oP '(?<=inet\s)\d+(\.\d+){3}'` echo -n `ip -4 addr show scope global | grep -o -m 1 -P '(?<=inet\s)\d+(\.\d+){3}'`
echo " port $PORT" echo " port $PORT"
echo "Configure your browser to use the above as http (and https) proxy." echo "Configure your browser to use the above as http (and https) proxy."
echo "" echo ""
} }
# Installs vsftpd (FTP server)
function installFtp() {
sudo apt-get update && sudo apt-get install vsftpd --assume-yes --no-install-recommends </dev/null
echo
echo "Connect to the FTP server with:"
echo -n "ftp://"
echo -n `ip -4 addr show scope global | grep -o -m 1 -P '(?<=inet\s)\d+(\.\d+){3}'`
echo "/"
echo
echo "Authenticate with username '$USER' and your password on this Pi."
echo
}
# Installs and configures Samba (SMB server) # Installs and configures Samba (SMB server)
function installSamba() { function installSamba() {
SAMBA_CONFIG_PATH="/etc/samba" SAMBA_CONFIG_PATH="/etc/samba"
@ -928,7 +946,7 @@ function installPiscsiScreen() {
if [[ $SKIP_PACKAGES ]]; then if [[ $SKIP_PACKAGES ]]; then
echo "Skipping package installation" echo "Skipping package installation"
else else
sudo apt-get update && sudo apt-get install libjpeg-dev libpng-dev libopenjp2-7-dev i2c-tools raspi-config -y </dev/null sudo apt-get update && sudo apt-get install libjpeg-dev libpng-dev libopenjp2-7-dev i2c-tools raspi-config --assume-yes --no-install-recommends </dev/null
fi fi
if [[ $(grep -c "^dtparam=i2c_arm=on" /boot/config.txt) -ge 1 ]]; then if [[ $(grep -c "^dtparam=i2c_arm=on" /boot/config.txt) -ge 1 ]]; then
@ -1002,9 +1020,9 @@ function installPiscsiCtrlBoard() {
if [[ $SKIP_PACKAGES ]]; then if [[ $SKIP_PACKAGES ]]; then
echo "Skipping package installation" echo "Skipping package installation"
else else
sudo apt-get update && sudo apt-get install libjpeg-dev libpng-dev libopenjp2-7-dev i2c-tools raspi-config -y </dev/null sudo apt-get update && sudo apt-get install libjpeg-dev libpng-dev libopenjp2-7-dev i2c-tools raspi-config --assume-yes --no-install-recommends </dev/null
# install python packages through apt that need compilation # install python packages through apt that need compilation
sudo apt-get install python3-cbor2 -y </dev/null sudo apt-get install python3-cbor2 --assume-yes --no-install-recommends </dev/null
fi fi
# enable i2c # enable i2c
@ -1091,8 +1109,6 @@ function notifyBackup {
# Creates the group and modifies current user for Web Interface auth # Creates the group and modifies current user for Web Interface auth
function enableWebInterfaceAuth { function enableWebInterfaceAuth {
AUTH_GROUP="piscsi"
if [ $(getent group "$AUTH_GROUP") ]; then if [ $(getent group "$AUTH_GROUP") ]; then
echo "The '$AUTH_GROUP' group already exists." echo "The '$AUTH_GROUP' group already exists."
echo "Do you want to disable Web Interface authentication? (y/N)" echo "Do you want to disable Web Interface authentication? (y/N)"
@ -1251,6 +1267,17 @@ function runChoice() {
echo "Installing AppleShare File Server - Complete!" echo "Installing AppleShare File Server - Complete!"
;; ;;
8) 8)
echo "Installing FTP File Server"
echo "This script will make the following changes to your system:"
echo " - Install packages with apt-get"
echo " - Enable the vsftpd systemd service"
echo "WARNING: The FTP server may transfer unencrypted data over the network."
echo "Proceed with this installation only if you are on a private, secure network."
sudoCheck
installFtp
echo "Installing FTP File Server - Complete!"
;;
9)
echo "Installing SMB File Server" echo "Installing SMB File Server"
echo "This script will make the following changes to your system:" echo "This script will make the following changes to your system:"
echo " - Install packages with apt-get" echo " - Install packages with apt-get"
@ -1261,7 +1288,7 @@ function runChoice() {
installSamba installSamba
echo "Installing SMB File Server - Complete!" echo "Installing SMB File Server - Complete!"
;; ;;
9) 10)
echo "Installing Web Proxy Server" echo "Installing Web Proxy Server"
echo "This script will make the following changes to your system:" echo "This script will make the following changes to your system:"
echo "- Install additional packages with apt-get" echo "- Install additional packages with apt-get"
@ -1271,7 +1298,7 @@ function runChoice() {
installMacproxy installMacproxy
echo "Installing Web Proxy Server - Complete!" echo "Installing Web Proxy Server - Complete!"
;; ;;
10) 11)
echo "Configuring PiSCSI stand-alone ($CONNECT_TYPE)" echo "Configuring PiSCSI stand-alone ($CONNECT_TYPE)"
echo "This script will make the following changes to your system:" echo "This script will make the following changes to your system:"
echo "- Install additional packages with apt-get" echo "- Install additional packages with apt-get"
@ -1288,7 +1315,7 @@ function runChoice() {
echo "Configuring PiSCSI stand-alone ($CONNECT_TYPE) - Complete!" echo "Configuring PiSCSI stand-alone ($CONNECT_TYPE) - Complete!"
echo "Use 'piscsi' to launch PiSCSI, and 'scsictl' to control the running process." echo "Use 'piscsi' to launch PiSCSI, and 'scsictl' to control the running process."
;; ;;
11) 12)
echo "Configuring PiSCSI Web Interface stand-alone" echo "Configuring PiSCSI Web Interface stand-alone"
echo "This script will make the following changes to your system:" echo "This script will make the following changes to your system:"
echo "- Install additional packages with apt-get" echo "- Install additional packages with apt-get"
@ -1308,7 +1335,7 @@ function runChoice() {
echo "Configuring PiSCSI Web Interface stand-alone - Complete!" echo "Configuring PiSCSI 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 --web-port=8081" echo "Launch the Web Interface with the 'start.sh' script. To use a custom port for the web server: 'start.sh --web-port=8081"
;; ;;
12) 13)
echo "Enabling or disabling PiSCSI back-end authentication" echo "Enabling or disabling PiSCSI back-end authentication"
echo "This script will make the following changes to your system:" echo "This script will make the following changes to your system:"
echo "- Modify user groups and permissions" echo "- Modify user groups and permissions"
@ -1318,7 +1345,7 @@ function runChoice() {
enablePiscsiService enablePiscsiService
echo "Enabling or disabling PiSCSI back-end authentication - Complete!" echo "Enabling or disabling PiSCSI back-end authentication - Complete!"
;; ;;
13) 14)
echo "Enabling or disabling Web Interface authentication" echo "Enabling or disabling Web Interface authentication"
echo "This script will make the following changes to your system:" echo "This script will make the following changes to your system:"
echo "- Modify user groups and permissions" echo "- Modify user groups and permissions"
@ -1326,11 +1353,11 @@ function runChoice() {
enableWebInterfaceAuth enableWebInterfaceAuth
echo "Enabling or disabling Web Interface authentication - Complete!" echo "Enabling or disabling Web Interface authentication - Complete!"
;; ;;
14) 15)
shareImagesWithNetatalk shareImagesWithNetatalk
echo "Configuring AppleShare File Server - Complete!" echo "Configuring AppleShare File Server - Complete!"
;; ;;
15) 16)
installPackagesStandalone installPackagesStandalone
compilePiscsi compilePiscsi
;; ;;
@ -1347,8 +1374,8 @@ function runChoice() {
function readChoice() { function readChoice() {
choice=-1 choice=-1
until [ $choice -ge "0" ] && [ $choice -le "15" ]; do until [ $choice -ge "0" ] && [ $choice -le "16" ]; do
echo -n "Enter your choice (0-15) or CTRL-C to exit: " echo -n "Enter your choice (0-16) or CTRL-C to exit: "
read -r choice read -r choice
done done
@ -1370,16 +1397,17 @@ function showMenu() {
echo " 6) Configure network bridge for WiFi (static IP + NAT)" echo " 6) Configure network bridge for WiFi (static IP + NAT)"
echo "INSTALL COMPANION APPS" echo "INSTALL COMPANION APPS"
echo " 7) Install AppleShare File Server (Netatalk)" echo " 7) Install AppleShare File Server (Netatalk)"
echo " 8) Install SMB File Server (Samba)" echo " 8) Install FTP File Server (vsftpd)"
echo " 9) Install Web Proxy Server (Macproxy)" echo " 9) Install SMB File Server (Samba)"
echo " 10) Install Web Proxy Server (Macproxy)"
echo "ADVANCED OPTIONS" echo "ADVANCED OPTIONS"
echo " 10) Compile and install PiSCSI stand-alone" echo " 11) Compile and install PiSCSI stand-alone"
echo " 11) Configure the PiSCSI Web Interface stand-alone" echo " 12) Configure the PiSCSI Web Interface stand-alone"
echo " 12) Enable or disable PiSCSI back-end authentication" echo " 13) Enable or disable PiSCSI back-end authentication"
echo " 13) Enable or disable PiSCSI Web Interface authentication" echo " 14) Enable or disable PiSCSI Web Interface authentication"
echo "EXPERIMENTAL FEATURES" echo "EXPERIMENTAL FEATURES"
echo " 14) Share the images dir over AppleShare (requires Netatalk)" echo " 15) Share the images dir over AppleShare (requires Netatalk)"
echo " 15) Compile PiSCSI binaries" echo " 16) Compile PiSCSI binaries"
} }
# parse arguments passed to the script # parse arguments passed to the script
@ -1395,8 +1423,8 @@ while [ "$1" != "" ]; do
CONNECT_TYPE=$VALUE CONNECT_TYPE=$VALUE
;; ;;
-r | --run_choice) -r | --run_choice)
if ! [[ $VALUE =~ ^[1-9][0-9]?$ && $VALUE -ge 1 && $VALUE -le 15 ]]; then if ! [[ $VALUE =~ ^[1-9][0-9]?$ && $VALUE -ge 1 && $VALUE -le 16 ]]; then
echo "ERROR: The run choice parameter must have a numeric value between 1 and 15" echo "ERROR: The run choice parameter must have a numeric value between 1 and 16"
exit 1 exit 1
fi fi
RUN_CHOICE=$VALUE RUN_CHOICE=$VALUE