Compare commits
2 Commits
565482764d
...
7d988b338c
Author | SHA1 | Date | |
---|---|---|---|
7d988b338c | |||
b3e284a547 |
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"
|
echo "Name not set, please set it with -n"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$phpver" ]; then
|
||||||
|
phpver=83;
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Building Docker Image..."
|
echo "Building Docker Image..."
|
||||||
user=$(whoami)
|
user=$(whoami)
|
||||||
uid=$(id -u)
|
uid=$(id -u)
|
||||||
if [ ! -d "$root_path/db" ]; then
|
|
||||||
mkdir -p "$root_path/db";
|
|
||||||
fi
|
|
||||||
if [ ! -d "$root_path/web" ]; then
|
if [ ! -d "$root_path/web" ]; then
|
||||||
mkdir -p "$root_path/web";
|
mkdir -p "$root_path/web";
|
||||||
fi
|
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 "Creating management scripts in root directory..."
|
||||||
echo "#!/usr/bin/env bash" > "$root_path/instance_start"
|
echo "#!/usr/bin/env bash" > "$root_path/instance_start"
|
||||||
echo "docker start $name" >> "$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 "#!/usr/bin/env bash" > "$root_path/instance_db_info"
|
||||||
echo "docker exec $name cat /var/lib/mysql/creds" >> "$root_path/instance_db_info"
|
echo "docker exec $name cat /var/lib/mysql/creds" >> "$root_path/instance_db_info"
|
||||||
chmod +x $root_path/instance_*
|
chmod +x $root_path/instance_*
|
||||||
echo "Waiting 120 seconds for setup to finish"
|
echo "Waiting 160 seconds for setup to finish"
|
||||||
sleep 120;
|
sleep 160;
|
||||||
echo "Installing WordPress..."
|
echo "Installing WordPress..."
|
||||||
wpdbuser=$(docker exec $name cat /var/lib/mysql/creds |grep User| awk -F ": " {'print $2'})
|
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'})
|
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
|
if [[ $environment == 'DEV' ]]; then
|
||||||
echo "Starting Dev Deployment"
|
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
|
dnf install -y MariaDB-server MariaDB-client memcached
|
||||||
nohup mysqld -umysql &
|
nohup mysqld -umysql &
|
||||||
if [ ! -f /var/lib/mysql/creds ]; then
|
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 "CREATE USER '"$mysql_user"'@'localhost' IDENTIFIED BY '"$mysql_password"';"
|
||||||
mysql -e "GRANT ALL PRIVILEGES ON *.* TO '"$mysql_user"'@'localhost' WITH GRANT OPTION;"
|
mysql -e "GRANT ALL PRIVILEGES ON *.* TO '"$mysql_user"'@'localhost' WITH GRANT OPTION;"
|
||||||
mysql -e "FLUSH PRIVILEGES;"
|
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 User: "$mysql_user > /var/lib/mysql/creds
|
||||||
echo "MySQL Password: "$mysql_password >> /var/lib/mysql/creds
|
echo "MySQL Password: "$mysql_password >> /var/lib/mysql/creds
|
||||||
echo "MySQL Database: devdb_"$mysql_db >> /var/lib/mysql/creds
|
echo "MySQL Database: devdb_"$mysql_db >> /var/lib/mysql/creds
|
||||||
cat /var/lib/mysql/creds
|
cat /var/lib/mysql/creds
|
||||||
|
|
||||||
fi
|
fi
|
||||||
/usr/bin/memcached -d -u $user
|
/usr/bin/memcached -d -u $user
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $environment == 'PROD' ]]; then
|
if [[ $environment == 'PROD' ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user