diff options
Diffstat (limited to 'server')
-rwxr-xr-x | server/bin/setserveraddr | 16 | ||||
-rwxr-xr-x | server/bin/settoken | 6 |
2 files changed, 5 insertions, 17 deletions
diff --git a/server/bin/setserveraddr b/server/bin/setserveraddr index cca279b8..e2724886 100755 --- a/server/bin/setserveraddr +++ b/server/bin/setserveraddr @@ -115,13 +115,7 @@ if [ -n "$SERVERIP" ]; then if [ $CHANGE == 1 ]; then # Restart OpenGnsys services. /etc/init.d/opengnsys restart - # If Repository is active, generating a new API token. source $DEFAULTFILE - if [ "$RUN_OGADMREPO" == "yes" ]; then - REPOKEY=$(php -r 'echo md5(uniqid(rand(), true));') - sed -i -e "s/ApiToken=.*/ApiToken=$REPOKEY/" $OPENGNSYS/etc/ogAdmRepo.cfg - sed -i -e "s/APITOKEN=.*/APITOKEN=$REPOKEY/" $OPENGNSYS/etc/ogAdmServer.cfg - fi # If OpenGnsys Server is active, updating the database. if [ "$RUN_OGADMSERVER" == "yes" ]; then source $OPENGNSYS/etc/ogAdmServer.cfg @@ -136,14 +130,6 @@ EOT "UPDATE entornos SET ipserveradm='$SERVERIP' WHERE identorno=1" - # If OpenGnsys Repository is active, updating IP address and API token. - if [ "$RUN_OGADMREPO" == "yes" ]; then - mysql --defaults-extra-file=$MYCNF -D "$CATALOG" -e \ - "UPDATE repositorios - SET ip='$SERVERIP', apikey='$REPOKEY' - WHERE ip='$OLDSERVERIP'" - unset REPOKEY - fi # Updating all menu URLs. mysql --defaults-extra-file=$MYCNF -D "$CATALOG" -e \ "UPDATE menus @@ -162,7 +148,7 @@ Manual tasks: - Check PXE files. - Log-in as Web Console user: - Check menu URLs. -${REPOKEY:+" - Update repository API token"} +- Note: Run "settoken" script to update authentication tokens. EOT else # Showing message if nothing changes. diff --git a/server/bin/settoken b/server/bin/settoken index dd98f06a..727dbe68 100755 --- a/server/bin/settoken +++ b/server/bin/settoken @@ -50,14 +50,14 @@ if [ "$SERVER" ]; then [ "${ANSWER,,}" != "y" ] && raiseError cancel "API tokens not updated" fi APIKEY=$(php -r 'echo md5(uniqid(rand(), true));') - sed -i "s/^APITOKEN=.*/APITOKEN=$APIKEY/" $SERVERCFG || raiseError access "Cannot update server file" + sed -i -n -e "/^APITOKEN=/!p" -e "$ a\APITOKEN=$APIKEY" $SERVERCFG || raiseError access "Cannot update server file" fi # Update repository token. if [ "$REPO" ]; then [ -w $REPOCFG ] || raiseError access "Repository configuration file" APIKEY=$(php -r 'echo md5(uniqid(rand(), true));') - sed -i "s/^ApiToken=.*/ApiToken=$APIKEY/" $REPOCFG || raiseError access "Cannot update repository file" + sed -i -n -e "/^ApiToken=/!p" -e "$ a\ApiToken=$APIKEY" $REPOCFG || raiseError access "Cannot update repository file" # If database is local, update it. source $SERVERCFG source $REPOCFG @@ -73,6 +73,8 @@ host=$datasource EOT mysql --defaults-extra-file="$MYCNF" --default-character-set=utf8 -D "$CATALOG" -e \ "UPDATE repositorios SET apikey='$APIKEY' WHERE ip='$IPlocal';" || raiseError access "Database error" + else + echo "Please, don't forget to update the authentication token for this repository on the web server (check the file ogAdmRepo.cfg)." fi fi |