Commit c0e434d9 authored by Joachim Mathes's avatar Joachim Mathes

TASK: Add shell init script

parent c1585bd4
#/usr/bin/env bash
check_project_status() {
[ -d /var/www/t3o/vendor ] && echo "Project seems to be initialized already." && exit 0
}
prepare_user_proserver() {
cat /home/vagrant/.ssh/authorized_keys > /home/proserver/.ssh/authorized_keys
}
initialize_project() {
cd /var/www/t3o
sudo -u proserver composer install
rm -rf typo3
sudo -u proserver ln -s t3o/html
}
acquire_database_password() {
TYPO3_DATABASE_PASSWORD=$(php -r '$configuration=include("/var/www/t3o/html/typo3conf/LocalConfiguration.php"); echo $configuration["DB"]["Connections"]["Default"]["password"];')
}
download_and_import_database() {
DATABASE_ROOT_PASSWORD=$(sudo cat /usr/local/etc/mysql-password)
cd /tmp
curl -LsO https://vpro0100.proserver.punkt.de/sql/t3o.sql.gz
mysql -u root -p${DATABASE_ROOT_PASSWORD} -e "CREATE DATABASE IF NOT EXISTS t3o"
mysql -u root -p${DATABASE_ROOT_PASSWORD} -e "GRANT ALL ON t3o.* TO t3o@localhost identified by '${TYPO3_DATABASE_PASSWORD}'"
gunzip < t3o.sql.gz | mysql -u root -p${DATABASE_ROOT_PASSWORD} t3o
}
restart_phpfpm() {
sudo /usr/local/etc/rc.d/php-fpm restart
}
RC=0
case $1 in
init)
check_project_status
prepare_user_proserver
initialize_project
acquire_database_password
download_and_import_database
restart_phpfpm
;;
*)
echo $"Usage: ./t3o init"
RC=2
esac
exit $RC
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment