From d3b3a8d60b38418cd41481d81e83b86b0e457a5d Mon Sep 17 00:00:00 2001 From: Martin Winkler Date: Thu, 8 Apr 2021 09:07:58 +0200 Subject: [PATCH] Download to tmp first in case of errors database creation from external script --- seqs/gitea.sh | 54 +++++++++++++-------------------------------------- 1 file changed, 13 insertions(+), 41 deletions(-) diff --git a/seqs/gitea.sh b/seqs/gitea.sh index bf243f0..1d5dcfc 100755 --- a/seqs/gitea.sh +++ b/seqs/gitea.sh @@ -75,7 +75,7 @@ step_5() { exe vi $giteaServiceLoc } -step_6_info() { echo -e "Starting $toolName service\n"; } +step_6_info() { echo "Starting $toolName service"; } step_6() { exe systemctl enable gitea exe systemctl start gitea @@ -86,8 +86,8 @@ step_6() { echo "Afterwards please execute step 20 to secure configuration" } -step_7_info() { echo -e "Show configuration notes\n"; } -step_7_alias() { ALIAS="config"; } +step_7_info() { echo "Show configuration notes"; } +step_7_alias() { ALIAS="notes"; } step_7() { echo -e "Final configuration notes for app.ini:\n\n" echo "$CONFIG_NOTES" @@ -113,40 +113,9 @@ NO_REPLY_ADDRESS = yourdomain.com # Allow more archives to be uploaded ALLOWED_TYPES=application/zip|application/gzip|application/x-zip|application/x-gzip|application/x-shellscript|text/markdown" -step_10_info() { echo -e "Create mysql database for $toolName\n"; } +step_10_info() { echo "Create mysql database for $toolName"; } step_10() { - local mysqlDatabase - local mysqlUser - local mysqlPass - - echo "Existing mysql databases:" - exe mysql -u root -e 'SHOW DATABASES;' - - echo -en "Enter database name: " - read mysqlDatabase - endCheckEmpty mysqlDatabase "database name" - exe mysql -u root -e 'CREATE DATABASE '$mysqlDatabase' CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;' - saveReturn $? - endReturn - - echo "Existing mysql user:" - exe mysql -u root -e 'SELECT User, Host FROM mysql.user;' - echo -en "Enter mysql user name: " - read mysqlUser - endCheckEmpty mysqlUser "user name" - - echo -en "Enter mysql user password: " - read mysqlPass - endCheckEmpty mysqlPass "password" - exe mysql -u root -e 'CREATE USER '"'"$mysqlUser"'"'@'"'"'localhost'"'"' IDENTIFIED BY '"'"$mysqlPass"'"';' - saveReturn $? - endReturn - - exe mysql -u root -e 'GRANT ALL PRIVILEGES ON '$mysqlDatabase'.* TO '"'"$mysqlUser"'"'@'"'"'localhost'"'"';' - saveReturn $? - endReturn - - exe mysql -u root -e 'FLUSH PRIVILEGES;' + exe "$WDIR/mysql.sh" -qq createdb --charset utf8mb4 } step_12_info() { @@ -160,23 +129,26 @@ step_12_info() { else echo "Download new version $giteaVersion to /usr/local/bin" fi - echo } step_12_alias() { ALIAS="upgrade"; } step_12() { + exe wget -O "$giteaDownLoc" $giteaDownload + endReturn -o $? "Download failed" + if [ -f "$giteaLoc" ] ; then local toolBackup="${giteaDir}/gitea_${versionNow}" exe service gitea stop saveReturn $? endReturn - echo -n "Backing up existing executable to ${toolBackup}..." - exe cp -ar "$giteaLoc" "$toolBackup" && echo "ok" + echoseq -n "Backing up existing executable to ${toolBackup}..." + exe cp -ar "$giteaLoc" "$toolBackup" && echoseq "ok" || echoseq "nok" fi - exe wget -O "$giteaLoc" $giteaDownload + exe mv "$giteaDownLoc" "$giteaLoc" exe chmod +x "$giteaLoc" exe service gitea start } versionNow=$(gitea --version | sed 's/.*version \([0-9.]\+\).*/\1/') +giteaDownLoc="/tmp/giteaDown" step_20_info() { echo "Secure settings after installation"; } step_20() { @@ -185,7 +157,7 @@ step_20() { } # Sequence Revision -VERSION_SEQREV=10 +VERSION_SEQREV=12 # Path to sequencer . /usr/local/bin/sequencer.sh