Create database function

This commit is contained in:
Bob Mottram 2016-01-21 09:35:50 +00:00
parent b30bf6b03d
commit f6f611a093
1 changed files with 19 additions and 28 deletions

View File

@ -525,6 +525,21 @@ function show_help {
exit 0 exit 0
} }
function create_database {
app_name="$1"
app_admin_password="$2"
if [ ! -d $INSTALL_DIR ]; then
mkdir $INSTALL_DIR
fi
echo "create database ${app_name};
CREATE USER '${app_name}admin'@'localhost' IDENTIFIED BY '${app_admin_password}';
GRANT ALL PRIVILEGES ON ${app_name}.* TO '${app_name}admin'@'localhost';
quit" > $INSTALL_DIR/batch.sql
chmod 600 $INSTALL_DIR/batch.sql
mysql -u root --password="$MARIADB_PASSWORD" < $INSTALL_DIR/batch.sql
shred -zu $INSTALL_DIR/batch.sql
}
function locale_setup { function locale_setup {
if grep -Fxq "locale_setup" $COMPLETION_FILE; then if grep -Fxq "locale_setup" $COMPLETION_FILE; then
return return
@ -6197,13 +6212,7 @@ function install_owncloud {
chmod 600 /home/$MY_USERNAME/README chmod 600 /home/$MY_USERNAME/README
fi fi
echo "create database owncloud; create_database owncloud "$OWNCLOUD_ADMIN_PASSWORD"
CREATE USER 'owncloudadmin'@'localhost' IDENTIFIED BY '$OWNCLOUD_ADMIN_PASSWORD';
GRANT ALL PRIVILEGES ON owncloud.* TO 'owncloudadmin'@'localhost';
quit" > $INSTALL_DIR/batch.sql
chmod 600 $INSTALL_DIR/batch.sql
mysql -u root --password="$MARIADB_PASSWORD" < $INSTALL_DIR/batch.sql
shred -zu $INSTALL_DIR/batch.sql
if [ ! -d /var/www/$OWNCLOUD_DOMAIN_NAME ]; then if [ ! -d /var/www/$OWNCLOUD_DOMAIN_NAME ]; then
mkdir /var/www/$OWNCLOUD_DOMAIN_NAME mkdir /var/www/$OWNCLOUD_DOMAIN_NAME
@ -6604,13 +6613,7 @@ function install_gogs {
chmod 600 /home/$MY_USERNAME/README chmod 600 /home/$MY_USERNAME/README
fi fi
echo "create database gogs; create_database gogs "$GOGS_ADMIN_PASSWORD"
CREATE USER 'gogsadmin'@'localhost' IDENTIFIED BY '$GOGS_ADMIN_PASSWORD';
GRANT ALL PRIVILEGES ON gogs.* TO 'gogsadmin'@'localhost';
quit" > $INSTALL_DIR/batch.sql
chmod 600 $INSTALL_DIR/batch.sql
mysql -u root --password="$MARIADB_PASSWORD" < $INSTALL_DIR/batch.sql
shred -zu $INSTALL_DIR/batch.sql
chmod 600 /home/git/go/src/github.com/gogits/gogs/custom/conf/app.ini chmod 600 /home/git/go/src/github.com/gogits/gogs/custom/conf/app.ini
@ -8187,13 +8190,7 @@ function install_gnu_social {
chmod 600 /home/$MY_USERNAME/README chmod 600 /home/$MY_USERNAME/README
fi fi
echo "create database gnusocial; create_database gnusocial "$MICROBLOG_ADMIN_PASSWORD"
CREATE USER 'gnusocialadmin'@'localhost' IDENTIFIED BY '$MICROBLOG_ADMIN_PASSWORD';
GRANT ALL PRIVILEGES ON gnusocial.* TO 'gnusocialadmin'@'localhost';
quit" > $INSTALL_DIR/batch.sql
chmod 600 $INSTALL_DIR/batch.sql
mysql -u root --password="$MARIADB_PASSWORD" < $INSTALL_DIR/batch.sql
shred -zu $INSTALL_DIR/batch.sql
if [ ! -f "/etc/aliases" ]; then if [ ! -f "/etc/aliases" ]; then
touch /etc/aliases touch /etc/aliases
@ -8585,13 +8582,7 @@ function install_hubzilla {
chmod 600 /home/$MY_USERNAME/README chmod 600 /home/$MY_USERNAME/README
fi fi
echo "create database hubzilla; create_database hubzilla "$HUBZILLA_ADMIN_PASSWORD"
CREATE USER 'hubzillaadmin'@'localhost' IDENTIFIED BY '$HUBZILLA_ADMIN_PASSWORD';
GRANT ALL PRIVILEGES ON hubzilla.* TO 'hubzillaadmin'@'localhost';
quit" > $INSTALL_DIR/batch.sql
chmod 600 $INSTALL_DIR/batch.sql
mysql -u root --password="$MARIADB_PASSWORD" < $INSTALL_DIR/batch.sql
shred -zu $INSTALL_DIR/batch.sql
if ! grep -q "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs" /etc/crontab; then if ! grep -q "/var/www/$HUBZILLA_DOMAIN_NAME/htdocs" /etc/crontab; then
echo "12,22,32,42,52 * * * * root cd /var/www/$HUBZILLA_DOMAIN_NAME/htdocs; /usr/bin/timeout 500 /usr/bin/php include/poller.php" >> /etc/crontab echo "12,22,32,42,52 * * * * root cd /var/www/$HUBZILLA_DOMAIN_NAME/htdocs; /usr/bin/timeout 500 /usr/bin/php include/poller.php" >> /etc/crontab