2024-10-14 19:15:11 +00:00
|
|
|
#!/usr/bin/env bash
|
2023-04-05 14:53:20 +00:00
|
|
|
|
2023-05-27 18:13:18 +00:00
|
|
|
if [ -z "$PHPVER" ]; then
|
|
|
|
PHPVER="81";
|
|
|
|
fi
|
|
|
|
|
2023-04-05 14:53:20 +00:00
|
|
|
adduser -u $uid $user
|
|
|
|
|
|
|
|
mkdir -p /home/$user/public_html
|
2024-10-15 02:30:51 +00:00
|
|
|
mkdir -p /home/$user/logs/{apache,php-fpm}
|
2023-04-05 14:53:20 +00:00
|
|
|
|
2024-10-15 02:30:51 +00:00
|
|
|
mv /var/log/httpd /var/log/httpd.bak
|
|
|
|
|
|
|
|
ln -s /home/$user/logs/apache /var/log/httpd
|
|
|
|
ln -s /home/$user/logs/php-fpm /var/log/php-fpm
|
2023-04-05 14:53:20 +00:00
|
|
|
|
2024-12-18 05:44:09 +00:00
|
|
|
rm -f /etc/httpd/conf.d/userdir.conf
|
|
|
|
docker_network=$(ip addr show |grep eth0 |grep inet |awk -F " " {'print $2'})
|
|
|
|
echo "RemoteIPInternalProxy $docker_network" >> /etc/httpd/conf.d/remoteip.conf
|
2023-05-27 18:13:18 +00:00
|
|
|
/scripts/install-php$PHPVER.sh
|
|
|
|
|
2023-04-05 14:53:20 +00:00
|
|
|
/scripts/create-vhost.sh
|
|
|
|
/scripts/create-php-config.sh
|
|
|
|
|
2024-10-15 02:30:51 +00:00
|
|
|
if [ -f /etc/httpd/conf.d/ssl.conf ]; then
|
|
|
|
mv /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.bak
|
|
|
|
fi
|
2024-10-14 19:15:11 +00:00
|
|
|
|
2023-04-05 14:53:20 +00:00
|
|
|
/usr/sbin/httpd -k start
|
|
|
|
/usr/sbin/php-fpm -y /etc/php-fpm.conf
|
2024-10-15 02:30:51 +00:00
|
|
|
chown -R $user:$user /home/$user
|
|
|
|
chmod -R 755 /home/$user
|
2023-04-05 14:53:20 +00:00
|
|
|
|
2023-04-07 00:27:02 +00:00
|
|
|
if [[ $environment == 'DEV' ]]; then
|
2023-04-05 14:53:20 +00:00
|
|
|
echo "Starting Dev Deployment"
|
2024-10-15 02:30:51 +00:00
|
|
|
mkdir -p /home/$user/_db_backups
|
2023-05-27 18:13:18 +00:00
|
|
|
dnf install -y MariaDB-server MariaDB-client memcached
|
2023-04-05 14:53:20 +00:00
|
|
|
nohup mysqld -umysql &
|
2024-10-14 19:15:11 +00:00
|
|
|
if [ ! -f /home/$user/mysql_creds ]; then
|
2023-04-05 14:53:20 +00:00
|
|
|
echo "Give MySQL a chance to finish starting..."
|
|
|
|
sleep 10
|
|
|
|
mysql_user=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13 ; echo '')
|
|
|
|
mysql_password=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 18 ; echo '')
|
|
|
|
mysql_db=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 6 ; echo '')
|
|
|
|
mysql -e "CREATE DATABASE devdb_"$mysql_db";"
|
|
|
|
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;"
|
2024-10-15 02:30:51 +00:00
|
|
|
echo "*/15 * * * * root /scripts/mysql-backup.sh $user devdb_$mysql_db" >> /etc/crontab
|
2024-10-14 19:15:11 +00:00
|
|
|
echo "MySQL User: "$mysql_user > /home/$user/mysql_creds
|
|
|
|
echo "MySQL Password: "$mysql_password >> /home/$user/mysql_creds
|
|
|
|
echo "MySQL Database: devdb_"$mysql_db >> /home/$user/mysql_creds
|
|
|
|
cat /home/$user/mysql_creds
|
2024-10-02 20:21:49 +00:00
|
|
|
|
2023-04-05 14:53:20 +00:00
|
|
|
fi
|
|
|
|
/usr/bin/memcached -d -u $user
|
2024-10-02 20:21:49 +00:00
|
|
|
|
2023-04-05 14:53:20 +00:00
|
|
|
fi
|
2024-08-13 01:20:00 +00:00
|
|
|
|
|
|
|
if [[ $environment == 'PROD' ]]; then
|
|
|
|
sed -r -i 's/;session.save_path="localhost:11211/session.save_path="memcache:11211/' /etc/php.d/50-memcached.ini
|
|
|
|
fi
|
2024-10-14 19:15:11 +00:00
|
|
|
/usr/sbin/crond
|
2024-10-15 02:30:51 +00:00
|
|
|
tail -f /var/log/httpd/*
|
2023-04-05 14:53:20 +00:00
|
|
|
|
|
|
|
exit 0
|
2024-08-13 01:20:00 +00:00
|
|
|
|