Download to tmp first in case of errors

database creation from external script
This commit is contained in:
2021-04-08 09:07:58 +02:00
parent 75663b3108
commit d3b3a8d60b

View File

@@ -75,7 +75,7 @@ step_5() {
exe vi $giteaServiceLoc exe vi $giteaServiceLoc
} }
step_6_info() { echo -e "Starting $toolName service\n"; } step_6_info() { echo "Starting $toolName service"; }
step_6() { step_6() {
exe systemctl enable gitea exe systemctl enable gitea
exe systemctl start gitea exe systemctl start gitea
@@ -86,8 +86,8 @@ step_6() {
echo "Afterwards please execute step 20 to secure configuration" echo "Afterwards please execute step 20 to secure configuration"
} }
step_7_info() { echo -e "Show configuration notes\n"; } step_7_info() { echo "Show configuration notes"; }
step_7_alias() { ALIAS="config"; } step_7_alias() { ALIAS="notes"; }
step_7() { step_7() {
echo -e "Final configuration notes for app.ini:\n\n" echo -e "Final configuration notes for app.ini:\n\n"
echo "$CONFIG_NOTES" echo "$CONFIG_NOTES"
@@ -113,40 +113,9 @@ NO_REPLY_ADDRESS = yourdomain.com
# Allow more archives to be uploaded # Allow more archives to be uploaded
ALLOWED_TYPES=application/zip|application/gzip|application/x-zip|application/x-gzip|application/x-shellscript|text/markdown" 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() { step_10() {
local mysqlDatabase exe "$WDIR/mysql.sh" -qq createdb --charset utf8mb4
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;'
} }
step_12_info() { step_12_info() {
@@ -160,23 +129,26 @@ step_12_info() {
else else
echo "Download new version $giteaVersion to /usr/local/bin" echo "Download new version $giteaVersion to /usr/local/bin"
fi fi
echo
} }
step_12_alias() { ALIAS="upgrade"; } step_12_alias() { ALIAS="upgrade"; }
step_12() { step_12() {
exe wget -O "$giteaDownLoc" $giteaDownload
endReturn -o $? "Download failed"
if [ -f "$giteaLoc" ] ; then if [ -f "$giteaLoc" ] ; then
local toolBackup="${giteaDir}/gitea_${versionNow}" local toolBackup="${giteaDir}/gitea_${versionNow}"
exe service gitea stop exe service gitea stop
saveReturn $? saveReturn $?
endReturn endReturn
echo -n "Backing up existing executable to ${toolBackup}..." echoseq -n "Backing up existing executable to ${toolBackup}..."
exe cp -ar "$giteaLoc" "$toolBackup" && echo "ok" exe cp -ar "$giteaLoc" "$toolBackup" && echoseq "ok" || echoseq "nok"
fi fi
exe wget -O "$giteaLoc" $giteaDownload exe mv "$giteaDownLoc" "$giteaLoc"
exe chmod +x "$giteaLoc" exe chmod +x "$giteaLoc"
exe service gitea start exe service gitea start
} }
versionNow=$(gitea --version | sed 's/.*version \([0-9.]\+\).*/\1/') versionNow=$(gitea --version | sed 's/.*version \([0-9.]\+\).*/\1/')
giteaDownLoc="/tmp/giteaDown"
step_20_info() { echo "Secure settings after installation"; } step_20_info() { echo "Secure settings after installation"; }
step_20() { step_20() {
@@ -185,7 +157,7 @@ step_20() {
} }
# Sequence Revision # Sequence Revision
VERSION_SEQREV=10 VERSION_SEQREV=12
# Path to sequencer # Path to sequencer
. /usr/local/bin/sequencer.sh . /usr/local/bin/sequencer.sh