summaryrefslogtreecommitdiffstats
path: root/server/bin/settoken
diff options
context:
space:
mode:
authorRamón M. Gómez <ramongomez@us.es>2019-10-16 12:18:22 +0200
committerRamón M. Gómez <ramongomez@us.es>2019-10-16 12:18:22 +0200
commitdde2db1684454f535bb8d331e31bd5ea9b9641a6 (patch)
tree5c11da747071cc3709315f4df4173b3ad2dee482 /server/bin/settoken
parent436abc7095b6d72df74c4193b5051c2b9399b325 (diff)
#925: Only the installer uses {{{settoken}}} script to generate authentication tokens.
Diffstat (limited to 'server/bin/settoken')
-rwxr-xr-xserver/bin/settoken6
1 files changed, 4 insertions, 2 deletions
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