Create gogs database before restoring from backup

This commit is contained in:
Bob Mottram 2016-07-25 20:31:20 +01:00
parent bcaf4f07fa
commit 2acf8f67ce
2 changed files with 510 additions and 493 deletions

View File

@ -37,6 +37,32 @@ GIT_DOMAIN_REPO="https://github.com/gogits/gogs"
GIT_ADMIN_PASSWORD= GIT_ADMIN_PASSWORD=
GOGS_COMMIT='3fb4f7f4980b4339fd9ef6a3ba5b0acab83d264d' GOGS_COMMIT='3fb4f7f4980b4339fd9ef6a3ba5b0acab83d264d'
function get_mariadb_git_admin_password {
if [ -f /home/$MY_USERNAME/README ]; then
if grep -q "Gogs admin user password" /home/$MY_USERNAME/README; then
GIT_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "Gogs admin user password" | awk -F ':' '{print $2}' | sed 's/^ *//')
fi
fi
}
function gogs_create_database {
function_check get_mariadb_git_admin_password
get_mariadb_git_admin_password
if [ ! $GIT_ADMIN_PASSWORD ]; then
if [ -f $IMAGE_PASSWORD_FILE ]; then
GIT_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)"
else
GIT_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
fi
fi
if [ ! $GIT_ADMIN_PASSWORD ]; then
return
fi
function_check create_database
create_database gogs "$GOGS_ADMIN_PASSWORD"
}
function reconfigure_gogs { function reconfigure_gogs {
echo -n '' echo -n ''
} }
@ -96,6 +122,9 @@ function restore_local_gogs {
fi fi
if [ ${#GIT_DOMAIN_NAME} -gt 2 ]; then if [ ${#GIT_DOMAIN_NAME} -gt 2 ]; then
function_check gogs_create_database
gogs_create_database
function_check restore_database function_check restore_database
restore_database gogs ${GIT_DOMAIN_NAME} restore_database gogs ${GIT_DOMAIN_NAME}
temp_restore_dir=/root/tempgogs temp_restore_dir=/root/tempgogs
@ -194,6 +223,10 @@ function restore_remote_gogs {
if grep -q "Gogs domain" $COMPLETION_FILE; then if grep -q "Gogs domain" $COMPLETION_FILE; then
GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}') GIT_DOMAIN_NAME=$(cat $COMPLETION_FILE | grep "Gogs domain" | awk -F ':' '{print $2}')
function_check gogs_create_database
gogs_create_database
function_check restore_database_from_friend function_check restore_database_from_friend
restore_database_from_friend gogs $GIT_DOMAIN_NAME restore_database_from_friend gogs $GIT_DOMAIN_NAME
if [ -d $SERVER_DIRECTORY/backup/gogs ]; then if [ -d $SERVER_DIRECTORY/backup/gogs ]; then
@ -346,14 +379,12 @@ function install_gogs {
function_check get_mariadb_password function_check get_mariadb_password
get_mariadb_password get_mariadb_password
function_check get_mariadb_git_admin_password function_check
get_mariadb_git_admin_password gogs_create_database
if [ ! $GIT_ADMIN_PASSWORD ]; then
if [ -f $IMAGE_PASSWORD_FILE ]; then if [ ! -f $GOPATH/src/github.com/gogits/gogs/scripts/mysql.sql ]; then
GIT_ADMIN_PASSWORD="$(printf `cat $IMAGE_PASSWORD_FILE`)" echo $'MySql template for Gogs was not found'
else exit 72528
GIT_ADMIN_PASSWORD="$(create_password ${MINIMUM_PASSWORD_LENGTH})"
fi
fi fi
if ! grep -q $"Gogs admin user password" /home/$MY_USERNAME/README; then if ! grep -q $"Gogs admin user password" /home/$MY_USERNAME/README; then
@ -385,12 +416,6 @@ function install_gogs {
chmod 600 /home/$MY_USERNAME/README chmod 600 /home/$MY_USERNAME/README
fi fi
function_check create_database
create_database gogs "$GOGS_ADMIN_PASSWORD"
if [ ! -f $GOPATH/src/github.com/gogits/gogs/scripts/mysql.sql ]; then
echo $'MySql template for Gogs was not found'
exit 72528
fi
function_check initialise_database function_check initialise_database
initialise_database gogs $GOPATH/src/github.com/gogits/gogs/scripts/mysql.sql initialise_database gogs $GOPATH/src/github.com/gogits/gogs/scripts/mysql.sql

View File

@ -132,14 +132,6 @@ function get_mariadb_webmail_admin_password {
fi fi
} }
function get_mariadb_git_admin_password {
if [ -f /home/$MY_USERNAME/README ]; then
if grep -q "Gogs admin user password" /home/$MY_USERNAME/README; then
GIT_ADMIN_PASSWORD=$(cat /home/$MY_USERNAME/README | grep "Gogs admin user password" | awk -F ':' '{print $2}' | sed 's/^ *//')
fi
fi
}
function install_mariadb { function install_mariadb {
if grep -Fxq "install_mariadb" $COMPLETION_FILE; then if grep -Fxq "install_mariadb" $COMPLETION_FILE; then
return return