Skip to content

Commit

Permalink
Bootstrap Fixes
Browse files Browse the repository at this point in the history
  - change bootstrap to use tag instead of branch
  - fix python versioning
  - fix boostrap variable scoping
  • Loading branch information
devopsec committed Apr 3, 2023
1 parent a659fed commit 2e7a312
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
8 changes: 6 additions & 2 deletions dsiprouter.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2837,10 +2837,14 @@ function removeInitService() {

function upgrade() {
local BS_SCRIPT_URL="https://github.com/dOpensource/dsiprouter/tree/${UPGRADE_RELEASE}/resources/upgrade/${UPGRADE_RELEASE}/scripts/bootstrap.sh"
local BOOTSTRAPPING_UPGRADE=${BOOTSTRAPPING_UPGRADE:-0}
local BS_UPGRADE=${BOOTSTRAPPING_UPGRADE:-0}

# check if the new function definitions need bootstrapped prior to upgrade
if (( $BOOTSTRAPPING_UPGRADE == 0 )) && curl -sf -I "$BS_SCRIPT_URL" -o /dev/null; then
if (( $BS_UPGRADE == 0 )) && curl -sf -I "$BS_SCRIPT_URL" -o /dev/null; then
BS_UPGRADE=1
fi
export BOOTSTRAPPING_UPGRADE=$BS_UPGRADE
if (( $BOOTSTRAPPING_UPGRADE == 1 )); then
curl -s "$BS_SCRIPT_URL" | bash -s upgrade -rel ${UPGRADE_RELEASE}
return $?
fi
Expand Down
4 changes: 3 additions & 1 deletion resources/upgrade/v0.72/scripts/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ export CREDS_MAX_LEN='64'
export HASH_ITERATIONS='10000'
export HASHED_CREDS_ENCODED_MAX_LEN='128'
export AESCTR_CREDS_ENCODED_MAX_LEN='160'
TAG_NAME='v0.72-rel'
REPO_URL='https://github.com/dOpensource/dsiprouter.git'
rm -f /etc/dsiprouter/.requirementsinstalled
rm -rf /tmp/dsiprouter 2>/dev/null
git clone --depth 1 -b v0.72 https://github.com/dOpensource/dsiprouter.git /tmp/dsiprouter
git clone --depth 1 -b "$TAG_NAME" "$REPO_URL" /tmp/dsiprouter
ln -sf /tmp/dsiprouter/resources/upgrade /opt/dsiprouter/resources/upgrade
. /tmp/dsiprouter/dsiprouter/dsip_lib.sh
. /tmp/dsiprouter/dsiprouter.sh upgrade -rel v0.72
7 changes: 3 additions & 4 deletions resources/upgrade/v0.72/scripts/migrate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fi

printdbg 'backing up configs just in case the upgrade fails'
BACKUP_DIR="/var/backups"
CURR_BACKUP_DIR="${BACKUP_DIR}/$(date '+%Y-%m-%d')"
CURR_BACKUP_DIR="${BACKUP_DIR}/$(date '+%s')"
mkdir -p ${CURR_BACKUP_DIR}/{opt/dsiprouter,var/lib/mysql,${HOME},etc/dsiprouter,etc/kamailio,etc/rtpengine}
cp -rf /opt/dsiprouter/. ${CURR_BACKUP_DIR}/opt/dsiprouter/
cp -rf /etc/kamailio/. ${CURR_BACKUP_DIR}/etc/kamailio/
Expand Down Expand Up @@ -581,12 +581,11 @@ if (( ${BOOTSTRAPPING_UPGRADE:-0} == 1 )); then
else
# fresh repo coming up
rm -rf /opt/dsiprouter
git clone --depth 1 -b v0.72 https://github.com/dOpensource/dsiprouter.git /opt/dsiprouter
git clone --depth 1 -b v0.72-rel https://github.com/dOpensource/dsiprouter.git /opt/dsiprouter
fi

printdbg 'installing python dependencies for the GUI'
python3 -m pip install -r ${DSIP_PROJECT_DIR}/gui/requirements.txt
python3 -m pip install --force-reinstall Werkzeug
python3 -m pip install --force-reinstall -r ${DSIP_PROJECT_DIR}/gui/requirements.txt

printdbg 'generating dynamic config files for the GUI'
dsiprouter configuredsip &&
Expand Down

0 comments on commit 2e7a312

Please sign in to comment.