Merge pull request 'Fixing script to add more time for startup and add backup crons for database' (#13) from fix-script into trunk
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 34s
All checks were successful
Cloud Apache Container / Build-and-Push (push) Successful in 34s
Reviewed-on: #13
This commit is contained in:
commit
7d988b338c
15
local-dev.sh
15
local-dev.sh
@ -36,16 +36,19 @@ if [ -z "$name" ]; then
|
||||
echo "Name not set, please set it with -n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -z "$phpver" ]; then
|
||||
phpver=83;
|
||||
fi
|
||||
|
||||
echo "Building Docker Image..."
|
||||
user=$(whoami)
|
||||
uid=$(id -u)
|
||||
if [ ! -d "$root_path/db" ]; then
|
||||
mkdir -p "$root_path/db";
|
||||
fi
|
||||
if [ ! -d "$root_path/web" ]; then
|
||||
mkdir -p "$root_path/web";
|
||||
fi
|
||||
$check_docker run -d -p "$http_port":80 -p "$https_port":443 -e PHPVER="$phpver":83 -e environment=DEV --mount type=bind,source="$root_path"/web,target=/home/"$user"/public_html --mount type=bind,source="$root_path"/db,target=/var/lib/mysql -e uid="$uid" -e user="$user" -e domain="$name-local.dev" --name "$name" repo.anhonesthost.net/cloud-hosting-platform/cac:latest
|
||||
$check_docker volume create "$name-mysql"
|
||||
$check_docker run --pull=always -d -p "$http_port":80 -p "$https_port":443 -e PHPVER=$phpver -e environment=DEV --mount type=bind,source="$root_path"/web,target=/home/"$user"/public_html -v"$name-mysql":/var/lib/mysql -e uid="$uid" -e user="$user" -e domain="$name-local.dev" --name "$name" repo.anhonesthost.net/cloud-hosting-platform/cac:latest
|
||||
echo "Creating management scripts in root directory..."
|
||||
echo "#!/usr/bin/env bash" > "$root_path/instance_start"
|
||||
echo "docker start $name" >> "$root_path/instance_start"
|
||||
@ -56,8 +59,8 @@ echo "docker exec $name bash -c 'tail -f /etc/httpd/logs/*'" >> "$root_path/inst
|
||||
echo "#!/usr/bin/env bash" > "$root_path/instance_db_info"
|
||||
echo "docker exec $name cat /var/lib/mysql/creds" >> "$root_path/instance_db_info"
|
||||
chmod +x $root_path/instance_*
|
||||
echo "Waiting 120 seconds for setup to finish"
|
||||
sleep 120;
|
||||
echo "Waiting 160 seconds for setup to finish"
|
||||
sleep 160;
|
||||
echo "Installing WordPress..."
|
||||
wpdbuser=$(docker exec $name cat /var/lib/mysql/creds |grep User| awk -F ": " {'print $2'})
|
||||
wpdbpass=$(docker exec $name cat /var/lib/mysql/creds |grep Password| awk -F ": " {'print $2'})
|
||||
|
@ -21,6 +21,9 @@ chmod -R 755 /home/$user
|
||||
|
||||
if [[ $environment == 'DEV' ]]; then
|
||||
echo "Starting Dev Deployment"
|
||||
dnf install -y cronie
|
||||
/usr/sbin/crond
|
||||
mkdir -p /home/$user/public_html/_db_backups
|
||||
dnf install -y MariaDB-server MariaDB-client memcached
|
||||
nohup mysqld -umysql &
|
||||
if [ ! -f /var/lib/mysql/creds ]; then
|
||||
@ -33,12 +36,18 @@ if [[ $environment == 'DEV' ]]; then
|
||||
mysql -e "CREATE USER '"$mysql_user"'@'localhost' IDENTIFIED BY '"$mysql_password"';"
|
||||
mysql -e "GRANT ALL PRIVILEGES ON *.* TO '"$mysql_user"'@'localhost' WITH GRANT OPTION;"
|
||||
mysql -e "FLUSH PRIVILEGES;"
|
||||
dt=$(date +%y%m%d-%T)
|
||||
echo "*/15 * * * * root /usr/bin/mysqldump $mysql_db > /home/$user/public_html/_db_backups/$mysql_db.$dt.sql" >> /etc/crontab
|
||||
echo "*/30 * * * * root /usr/bin/find /home/$user/public_html/_db_backups/ -type f -mmin +360 -delete" >> /etc/crontab
|
||||
-type f -mmin +360
|
||||
echo "MySQL User: "$mysql_user > /var/lib/mysql/creds
|
||||
echo "MySQL Password: "$mysql_password >> /var/lib/mysql/creds
|
||||
echo "MySQL Database: devdb_"$mysql_db >> /var/lib/mysql/creds
|
||||
cat /var/lib/mysql/creds
|
||||
|
||||
fi
|
||||
/usr/bin/memcached -d -u $user
|
||||
|
||||
fi
|
||||
|
||||
if [[ $environment == 'PROD' ]]; then
|
||||
|
Loading…
Reference in New Issue
Block a user