From 7e4a5fec09bd349b13ae4b99dbce8378a9a45170 Mon Sep 17 00:00:00 2001 From: c-gabri Date: Sat, 4 Oct 2025 16:32:16 +0200 Subject: [PATCH 1/6] [feature] Allow custom install/upgrade path in auto-install.sh #514 Fixes #514 --- deploy/auto-install.sh | 30 ++++++++++++++++++++---------- docs/user/quickstart.rst | 13 +++++++------ 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/deploy/auto-install.sh b/deploy/auto-install.sh index 356b79ef..8d1fa0fc 100755 --- a/deploy/auto-install.sh +++ b/deploy/auto-install.sh @@ -1,10 +1,7 @@ #!/bin/bash export DEBIAN_FRONTEND=noninteractive -export INSTALL_PATH=/opt/openwisp/docker-openwisp -export LOG_FILE=/opt/openwisp/autoinstall.log -export ENV_USER=/opt/openwisp/config.env -export ENV_BACKUP=/opt/openwisp/backup.env +export USER_INSTALL_PATH=/opt/openwisp export GIT_PATH=${GIT_PATH:-https://github.com/openwisp/docker-openwisp.git} # Terminal colors @@ -72,8 +69,8 @@ setup_docker() { if [ $? -eq 0 ]; then report_ok else - curl -fsSL 'https://get.docker.com' -o '/opt/openwisp/get-docker.sh' &>>$LOG_FILE - sh '/opt/openwisp/get-docker.sh' &>>$LOG_FILE + curl -fsSL 'https://get.docker.com' -o '${USER_INSTALL_PATH}/get-docker.sh' &>>$LOG_FILE + sh '${USER_INSTALL_PATH}/get-docker.sh' &>>$LOG_FILE docker info &>/dev/null check_status $? "Docker installation failed." fi @@ -249,7 +246,7 @@ init_setup() { echo -e " - Supported systems" echo -e " - Debian: 11, 12 & 13" echo -e " - Ubuntu 22.04 & 24.04" - echo -e ${YLW}"\nYou can use -u\--upgrade if you are upgrading from an older version.\n"${NON} + echo -e ${YLW}"\nYou can use -u\--upgrade ${USER_INSTALL_PATH} if you are upgrading from an older version.\n"${NON} fi if [ "$EUID" -ne 0 ]; then @@ -257,7 +254,7 @@ init_setup() { exit 1 fi - mkdir -p /opt/openwisp + mkdir -p ${USER_INSTALL_PATH} echo "" >$LOG_FILE start_step "Checking your system capabilities..." @@ -297,8 +294,8 @@ init_help() { echo -e " - Supported systems" echo -e " - Debian: 11, 12 & 13" echo -e " - Ubuntu 22.04 & 24.04\n" - echo -e " -i\--install : (default) Install OpenWISP" - echo -e " -u\--upgrade : Change OpenWISP version already setup with this script" + echo -e " -i\--install [install-path]: (default) Install OpenWISP. Default path is /opt/openwisp" + echo -e " -u\--upgrade [install-path]: Change OpenWISP version already setup with this script" echo -e " -h\--help : See this help message" echo -e ${NON} } @@ -311,9 +308,22 @@ while test $# != 0; do -h | --help) action='help' ;; *) action='help' ;; esac + case "$1" in + -i | --install | -u | --upgrade) + if [[ -n "$2" ]]; then + USER_INSTALL_PATH=$(realpath -m "$2") + fi + shift + ;; + esac shift done +export INSTALL_PATH=${USER_INSTALL_PATH}/docker-openwisp +export LOG_FILE=${USER_INSTALL_PATH}/autoinstall.log +export ENV_USER=${USER_INSTALL_PATH}/config.env +export ENV_BACKUP=${USER_INSTALL_PATH}/backup.env + ## Init script if [[ "$action" == "help" ]]; then init_help diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index e8eb4b78..f2803a86 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -72,15 +72,16 @@ script and execute it: .. code-block:: bash curl https://raw.githubusercontent.com/openwisp/docker-openwisp/master/deploy/auto-install.sh -o auto-install.sh - sudo bash auto-install.sh + sudo bash auto-install.sh [--install install-path] -The auto-install script maintains a log, which is useful for debugging or -checking the real-time output of the script. You can view the log by -running the following command: +The default installation path is /opt/openwisp. The auto-install script +maintains a log, which is useful for debugging or checking the real-time +output of the script. You can view the log by running the following +command: .. code-block:: bash - tail -n 50 -f /opt/openwisp/autoinstall.log + tail -n 50 -f /autoinstall.log The auto-install script can be used to upgrade installations that were originally deployed using this script. You can upgrade your installation @@ -88,7 +89,7 @@ by using the following command .. code-block:: bash - sudo bash auto-install.sh --upgrade + sudo bash auto-install.sh --upgrade [install-path] .. note:: From 3f352fe41749f76cb735853e546159c3bde6c674 Mon Sep 17 00:00:00 2001 From: c-gabri Date: Sun, 5 Oct 2025 08:54:45 +0200 Subject: [PATCH 2/6] [docs] Fix formatting of quickstart.rst #514 Fixes #514 --- docs/user/quickstart.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index f2803a86..448a196d 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -74,10 +74,10 @@ script and execute it: curl https://raw.githubusercontent.com/openwisp/docker-openwisp/master/deploy/auto-install.sh -o auto-install.sh sudo bash auto-install.sh [--install install-path] -The default installation path is /opt/openwisp. The auto-install script -maintains a log, which is useful for debugging or checking the real-time -output of the script. You can view the log by running the following -command: +The default installation path is ``/opt/openwisp``. The auto-install +script maintains a log, which is useful for debugging or checking the +real-time output of the script. You can view the log by running the +following command: .. code-block:: bash From a546fe3c2c03cc86b7b3677b95ee38e166d4f59f Mon Sep 17 00:00:00 2001 From: Federico Capoano Date: Tue, 10 Mar 2026 20:10:43 -0300 Subject: [PATCH 3/6] [chores] Minor improvements --- deploy/auto-install.sh | 59 +++++++++++++------------- docs/user/quickstart.rst | 16 ++++--- images/openwisp_dashboard/openvpn.json | 16 +++---- 3 files changed, 47 insertions(+), 44 deletions(-) diff --git a/deploy/auto-install.sh b/deploy/auto-install.sh index 8839bf25..771840d5 100755 --- a/deploy/auto-install.sh +++ b/deploy/auto-install.sh @@ -11,17 +11,17 @@ export YLW='\033[1;33m' export BLU='\033[1;34m' export NON='\033[0m' -start_step() { printf '\e[1;34m%-70s\e[m' "$1" && echo "$1" &>>$LOG_FILE; } +start_step() { printf '\e[1;34m%-70s\e[m' "$1" && echo "$1" &>>"$LOG_FILE"; } report_ok() { echo -e ${GRN}" done"${NON}; } report_error() { echo -e ${RED}" error"${NON}; } get_env() { grep "^$1" "$2" | cut -d'=' -f 2-50; } set_env() { - line=$(grep -n "^$1=" $INSTALL_PATH/.env) + line=$(grep -n "^$1=" "$INSTALL_PATH/.env") if [ -z "$line" ]; then - echo "$1=$2" >>$INSTALL_PATH/.env + echo "$1=$2" >>"$INSTALL_PATH/.env" else line_number=$(echo $line | cut -f1 -d:) - eval $(echo "awk -i inplace 'NR=="${line_number}" {\$0=\"${1}=${2}\"}1' $INSTALL_PATH/.env") + eval $(echo "awk -i inplace 'NR=="${line_number}" {\$0=\"${1}=${2}\"}1' \"$INSTALL_PATH/.env\"") fi } @@ -51,7 +51,7 @@ error_msg_with_continue() { apt_dependenices_setup() { start_step "Setting up dependencies..." - apt --yes install python3 python3-pip git python3-dev gawk libffi-dev libssl-dev gcc make curl jq &>>$LOG_FILE + apt --yes install python3 python3-pip git python3-dev gawk libffi-dev libssl-dev gcc make curl jq &>>"$LOG_FILE" check_status $? "Python dependencies installation failed." } @@ -69,8 +69,8 @@ setup_docker() { if [ $? -eq 0 ]; then report_ok else - curl -fsSL 'https://get.docker.com' -o '${USER_INSTALL_PATH}/get-docker.sh' &>>$LOG_FILE - sh '${USER_INSTALL_PATH}/get-docker.sh' &>>$LOG_FILE + curl -fsSL 'https://get.docker.com' -o "${USER_INSTALL_PATH}/get-docker.sh" &>>"$LOG_FILE" + sh "${USER_INSTALL_PATH}/get-docker.sh" &>>"$LOG_FILE" docker info &>/dev/null check_status $? "Docker installation failed." fi @@ -79,9 +79,9 @@ setup_docker() { download_docker_openwisp() { local openwisp_version="$1" start_step "Downloading docker-openwisp..." - if [[ -f $INSTALL_PATH/.env ]]; then - mv $INSTALL_PATH/.env $ENV_BACKUP &>>$LOG_FILE - rm -rf $INSTALL_PATH &>>$LOG_FILE + if [[ -f "$INSTALL_PATH/.env" ]]; then + mv "$INSTALL_PATH/.env" "$ENV_BACKUP" &>>"$LOG_FILE" + rm -rf "$INSTALL_PATH" &>>"$LOG_FILE" fi if [ -z "$GIT_BRANCH" ]; then if [[ "$openwisp_version" == "edge" ]]; then @@ -91,7 +91,7 @@ download_docker_openwisp() { fi fi - git clone $GIT_PATH $INSTALL_PATH --depth 1 --branch $GIT_BRANCH &>>$LOG_FILE + git clone "$GIT_PATH" "$INSTALL_PATH" --depth 1 --branch "$GIT_BRANCH" &>>"$LOG_FILE" } setup_docker_openwisp() { @@ -117,15 +117,15 @@ setup_docker_openwisp() { echo -ne ${GRN}"(5/5) Use Let's Encrypt SSL? (y/N, blank for no): "${NON} read use_letsencrypt else - cp $env_path $ENV_USER &>>$LOG_FILE + cp "$env_path" "$ENV_USER" &>>"$LOG_FILE" fi echo "" download_docker_openwisp "$openwisp_version" - cd $INSTALL_PATH &>>$LOG_FILE + cd "$INSTALL_PATH" &>>"$LOG_FILE" check_status $? "docker-openwisp download failed." - echo $openwisp_version >$INSTALL_PATH/VERSION + echo $openwisp_version >"$INSTALL_PATH/VERSION" if [[ ! -f "$env_path" ]]; then # Dashboard Domain @@ -155,8 +155,8 @@ setup_docker_openwisp() { # Site manager email set_env "EMAIL_DJANGO_DEFAULT" "$django_default_email" # Set random secret values - python3 $INSTALL_PATH/build.py change-secret-key >/dev/null - python3 $INSTALL_PATH/build.py change-database-credentials >/dev/null + python3 "$INSTALL_PATH/build.py" change-secret-key >/dev/null + python3 "$INSTALL_PATH/build.py" change-database-credentials >/dev/null # SSL Configuration use_letsencrypt_lower=$(echo "$use_letsencrypt" | tr '[:upper:]' '[:lower:]') if [[ "$use_letsencrypt_lower" == "y" || "$use_letsencrypt_lower" == "yes" ]]; then @@ -169,14 +169,14 @@ setup_docker_openwisp() { set_env "POSTFIX_ALLOWED_SENDER_DOMAINS" "$hostname" set_env "POSTFIX_MYHOSTNAME" "$hostname" else - mv $ENV_USER $INSTALL_PATH/.env &>>$LOG_FILE - rm -rf $ENV_USER &>>$LOG_FILE + mv "$ENV_USER" "$INSTALL_PATH/.env" &>>"$LOG_FILE" + rm -rf "$ENV_USER" &>>"$LOG_FILE" fi start_step "Configuring docker-openwisp..." report_ok start_step "Starting images docker-openwisp (this will take a while)..." - make start TAG=$(cat $INSTALL_PATH/VERSION) -C $INSTALL_PATH/ &>>$LOG_FILE + make start TAG=$(cat "$INSTALL_PATH/VERSION") -C "$INSTALL_PATH/" &>>"$LOG_FILE" check_status $? "Starting openwisp failed." } @@ -187,19 +187,19 @@ upgrade_docker_openwisp() { download_docker_openwisp "$openwisp_version" - cd $INSTALL_PATH &>>$LOG_FILE + cd "$INSTALL_PATH" &>>"$LOG_FILE" check_status $? "docker-openwisp download failed." - echo $openwisp_version >$INSTALL_PATH/VERSION + echo $openwisp_version >"$INSTALL_PATH/VERSION" start_step "Configuring docker-openwisp..." - for config in $(grep '=' $ENV_BACKUP | cut -f1 -d'='); do + for config in $(grep '=' "$ENV_BACKUP" | cut -f1 -d'='); do value=$(get_env "$config" "$ENV_BACKUP") set_env "$config" "$value" done report_ok start_step "Starting images docker-openwisp (this will take a while)..." - make start TAG=$(cat $INSTALL_PATH/VERSION) -C $INSTALL_PATH/ &>>$LOG_FILE + make start TAG=$(cat "$INSTALL_PATH/VERSION") -C "$INSTALL_PATH/" &>>"$LOG_FILE" check_status $? "Starting openwisp failed." } @@ -256,12 +256,12 @@ init_setup() { exit 1 fi - mkdir -p ${USER_INSTALL_PATH} - echo "" >$LOG_FILE + mkdir -p "${USER_INSTALL_PATH}" + echo "" >"$LOG_FILE" start_step "Checking your system capabilities..." - apt update &>>$LOG_FILE - apt -qq --yes install lsb-release &>>$LOG_FILE + apt update &>>"$LOG_FILE" + apt -qq --yes install lsb-release &>>"$LOG_FILE" system_id=$(lsb_release --id --short) system_release=$(lsb_release --release --short) incompatible_message="$system_id $system_release is not supported. Installation might fail, continue anyway? (Y/n): " @@ -312,10 +312,11 @@ while test $# != 0; do esac case "$1" in -i | --install | -u | --upgrade) - if [[ -n "$2" ]]; then + # Check if next argument exists and is not another flag (starts with -) + if [[ -n "$2" && "$2" != -* ]]; then USER_INSTALL_PATH=$(realpath -m "$2") + shift fi - shift ;; esac shift diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index 448a196d..c90d9135 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -72,16 +72,18 @@ script and execute it: .. code-block:: bash curl https://raw.githubusercontent.com/openwisp/docker-openwisp/master/deploy/auto-install.sh -o auto-install.sh - sudo bash auto-install.sh [--install install-path] + sudo bash auto-install.sh # [--install install-path] -The default installation path is ``/opt/openwisp``. The auto-install -script maintains a log, which is useful for debugging or checking the -real-time output of the script. You can view the log by running the -following command: +The default installation path is ``/opt/openwisp`` and may be changed if +needed with the ``--install`` flag. + +The auto-install script maintains a log, which is useful for debugging or +checking the real-time output of the script. You can view the log by +running the following command: .. code-block:: bash - tail -n 50 -f /autoinstall.log + tail -n 50 -f /opt/openwisp/autoinstall.log # assuming default install path The auto-install script can be used to upgrade installations that were originally deployed using this script. You can upgrade your installation @@ -89,7 +91,7 @@ by using the following command .. code-block:: bash - sudo bash auto-install.sh --upgrade [install-path] + sudo bash auto-install.sh --upgrade # [install-path] .. note:: diff --git a/images/openwisp_dashboard/openvpn.json b/images/openwisp_dashboard/openvpn.json index 68787bec..5f949720 100644 --- a/images/openwisp_dashboard/openvpn.json +++ b/images/openwisp_dashboard/openvpn.json @@ -12,14 +12,14 @@ "comp_lzo": "no", "auth": "SHA1", "data_ciphers": [ - { - "cipher": "AES-128-GCM", - "optional": false - }, - { - "cipher": "none", - "optional": false - } + { + "cipher": "AES-128-GCM", + "optional": false + }, + { + "cipher": "none", + "optional": false + } ], "data_ciphers_fallback": "AES-128-GCM", "cipher": "AES-128-GCM", From 9080740b07d47038f70b958ac9dfa320ac9beda0 Mon Sep 17 00:00:00 2001 From: Federico Capoano Date: Tue, 10 Mar 2026 20:54:20 -0300 Subject: [PATCH 4/6] [docs] Minor improvements --- docs/user/quickstart.rst | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index c90d9135..692c2aa8 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -72,7 +72,11 @@ script and execute it: .. code-block:: bash curl https://raw.githubusercontent.com/openwisp/docker-openwisp/master/deploy/auto-install.sh -o auto-install.sh - sudo bash auto-install.sh # [--install install-path] + # Default installation (to /opt/openwisp): + sudo bash auto-install.sh + + # To use a custom installation path: + sudo bash auto-install.sh --install /path/to/install The default installation path is ``/opt/openwisp`` and may be changed if needed with the ``--install`` flag. @@ -91,7 +95,11 @@ by using the following command .. code-block:: bash - sudo bash auto-install.sh --upgrade # [install-path] + # Upgrade default installation: + sudo bash auto-install.sh --upgrade + + # If you used a custom installation path: + sudo bash auto-install.sh --upgrade --install /path/to/install .. note:: From bf4963c907303a71fb300f893be44105d707c555 Mon Sep 17 00:00:00 2001 From: Federico Capoano Date: Tue, 10 Mar 2026 21:05:32 -0300 Subject: [PATCH 5/6] [chores] Apply suggestions from code review Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- deploy/auto-install.sh | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/deploy/auto-install.sh b/deploy/auto-install.sh index 771840d5..df143fd1 100755 --- a/deploy/auto-install.sh +++ b/deploy/auto-install.sh @@ -122,10 +122,9 @@ setup_docker_openwisp() { echo "" download_docker_openwisp "$openwisp_version" - - cd "$INSTALL_PATH" &>>"$LOG_FILE" + cd "$INSTALL_PATH" || exit 1 check_status $? "docker-openwisp download failed." - echo $openwisp_version >"$INSTALL_PATH/VERSION" + echo "$openwisp_version" >"$INSTALL_PATH/VERSION" if [[ ! -f "$env_path" ]]; then # Dashboard Domain @@ -186,10 +185,9 @@ upgrade_docker_openwisp() { echo "" download_docker_openwisp "$openwisp_version" - - cd "$INSTALL_PATH" &>>"$LOG_FILE" + cd "$INSTALL_PATH" || exit 1 check_status $? "docker-openwisp download failed." - echo $openwisp_version >"$INSTALL_PATH/VERSION" + echo "$openwisp_version" >"$INSTALL_PATH/VERSION" start_step "Configuring docker-openwisp..." for config in $(grep '=' "$ENV_BACKUP" | cut -f1 -d'='); do From 12f00c60322bb0ac57fff432ba85032964e24c51 Mon Sep 17 00:00:00 2001 From: Federico Capoano Date: Tue, 10 Mar 2026 21:13:16 -0300 Subject: [PATCH 6/6] [chores] Update docs/user/quickstart.rst Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docs/user/quickstart.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/user/quickstart.rst b/docs/user/quickstart.rst index 692c2aa8..8e136e15 100644 --- a/docs/user/quickstart.rst +++ b/docs/user/quickstart.rst @@ -99,7 +99,7 @@ by using the following command sudo bash auto-install.sh --upgrade # If you used a custom installation path: - sudo bash auto-install.sh --upgrade --install /path/to/install + sudo bash auto-install.sh --upgrade /path/to/install .. note::