65 lines
1.9 KiB
Bash
65 lines
1.9 KiB
Bash
#!/usr/bin/env bash
|
|
|
|
if [ -z "$PHPVER" ]; then
|
|
PHPVER="81";
|
|
fi
|
|
|
|
adduser -u $uid $user
|
|
|
|
mkdir -p /home/$user/public_html
|
|
mkdir -p /home/$user/logs/{apache,php-fpm}
|
|
|
|
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
|
|
|
|
/scripts/install-php$PHPVER.sh
|
|
|
|
/scripts/create-vhost.sh
|
|
/scripts/create-php-config.sh
|
|
|
|
if [ -f /etc/httpd/conf.d/ssl.conf ]; then
|
|
mv /etc/httpd/conf.d/ssl.conf /etc/httpd/conf.d/ssl.conf.bak
|
|
fi
|
|
|
|
/usr/sbin/httpd -k start
|
|
/usr/sbin/php-fpm -y /etc/php-fpm.conf
|
|
chown -R $user:$user /home/$user
|
|
chmod -R 755 /home/$user
|
|
|
|
if [[ $environment == 'DEV' ]]; then
|
|
echo "Starting Dev Deployment"
|
|
mkdir -p /home/$user/_db_backups
|
|
dnf install -y MariaDB-server MariaDB-client memcached
|
|
nohup mysqld -umysql &
|
|
if [ ! -f /home/$user/mysql_creds ]; then
|
|
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;"
|
|
echo "*/15 * * * * root /scripts/mysql-backup.sh $user devdb_$mysql_db" >> /etc/crontab
|
|
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
|
|
|
|
fi
|
|
/usr/bin/memcached -d -u $user
|
|
|
|
fi
|
|
|
|
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
|
|
/usr/sbin/crond
|
|
tail -f /var/log/httpd/*
|
|
|
|
exit 0
|
|
|