Skip to content

Instantly share code, notes, and snippets.

@protos1575

protos1575/install.sh

Last active Sep 20, 2016
Embed
What would you like to do?
Typo3dist-auto-install für mac osx
#!/bin/bash
domain=$1
red_bg="\033[41m"
green_bg="\033[42m"
yellow_bg="\033[43m"
white_text="\033[37m"
clear="\033[0m"
# PATH TO YOUR HOSTS FILE
ETC_HOSTS=/etc/hosts
# DEFAULT IP FOR HOSTNAME
IP="127.0.0.1"
function addhost() {
HOSTNAME=$1
HOSTS_LINE="$IP\t$domain"
if [ -n "$(grep $domain /etc/hosts)" ]
then
echo -e "${red_bg}${white_text}$domain already exists : $(grep $domain $ETC_HOSTS)${clear}"
else
echo -e "${green_bg}${white_text}Adding $domain to your $ETC_HOSTS${clear}";
sudo -- sh -c -e "echo '$HOSTS_LINE' >> /etc/hosts";
if [ -n "$(grep $domain /etc/hosts)" ]
then
echo -e "${green_bg}${white_text}$domain was added succesfully \n $(grep $domain /etc/hosts)${clear}";
else
echo -e "${red_bg}${white_text}Failed to Add $domain, Try again!${clear}";
fi
fi
}
if [ -z "$domain" ]; then
echo -e "${red_bg}${white_text}Please type domainname at first arg!${clear}"
else
file="/etc/apache2/vhosts/$domain.conf"
if [ -f "$file" ]
then
echo -e "${red_bg}${white_text}A vhost: $file found. Script can't continue. Please chose an other name!${clear}"
exit
else
echo -e "${green_bg}${white_text}A vhost with $file dosen't exist. Script create the vhost entry.${clear}"
fi
user=$(whoami)
pwd=$(pwd)
echo -e "${green_bg}${white_text}Clone Composer into $domain.${clear}"
git clone git@github.com:protos1575/TYPO3-Distribution.git $domain
cd $domain
echo -e "${yellow_bg}${white_text}Please type your sudo pwd for changing ownership and acces rights of the new folder to $user:_www .${clear}"
sudo chown -R $user:_www .
echo -e "${yellow_bg}${white_text}Change access rights."
sudo chmod -R g+w .
echo -e "${green_bg}${white_text}Clean up git an init new repo.${clear}"
rm -rf .git && git init && git add . && git commit -m "Initial commit after kickstart"
echo -e "${green_bg}${white_text}Generate new vhost entry.${clear}"
sudo bash -c "cat <<EOF > /etc/apache2/vhosts/${domain}.conf
<VirtualHost *:80>
DocumentRoot \"${pwd}/${domain}/web\"
ServerName ${domain}
ServerAlias ${domain}.*.xip.io
ErrorLog \"/private/var/log/apache2/error_log\"
CustomLog \"/private/var/log/apache2/access_log\" common
<Directory \"${pwd}/${domain}/web\">
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
EOF"
echo -e "${green_bg}${white_text}Install TYPO3 via Composer.${clear}"
composer install
echo -e "${green_bg}${white_text}Start TYPO3 setup.${clear}"
./typo3cms install:setup
echo -e "${green_bg}${white_text}Writing configuration to .env file."${clear}
cp .env-example .env-temp
sed -i -- "s/TYPO3__DB__database=\"your_database\"/TYPO3__DB__database=\"$(./typo3cms configuration:show DB | sed -n -E "s/(.*'database' => '(.*)',).*$/\2/p")\"/g" .env-temp
sed -i -- "s/TYPO3__DB__host=\"localhost\"/TYPO3__DB__host=\"$(./typo3cms configuration:show DB | sed -n -E "s/(.*'host' => '(.*)',).*$/\2/p")\"/g" .env-temp
sed -i -- "s/TYPO3__DB__password=\"root\"/TYPO3__DB__password=\"$(./typo3cms configuration:show DB | sed -n -E "s/(.*'password' => '(.*)',).*$/\2/p")\"/g" .env-temp
sed -i -- "s/TYPO3__DB__username=\"root\"/TYPO3__DB__username=\"$(./typo3cms configuration:show DB | sed -n -E "s/(.*'username' => '(.*)',).*$/\2/p")\"/g" .env-temp
rm .env-temp--
mv .env-temp .env
echo -e "${green_bg}${white_text}Remove DB from configuration.${clear}"
./typo3cms configuration:remove DB --force
echo -e "${yellow_bg}${white_text}Please type your sudo pwd for changing ownership and acces rights of the new folder to $user:_www .${clear}"
sudo chown -R $user:_www .
echo -e "${yellow_bg}${white_text}Change access rights."
sudo chmod -R g+w .
echo -e "${green_bg}${white_text}Commit after install.${clear}"
git add . && git commit -m "After Install"
echo -e "${green_bg}${white_text}Copy .htaccess to webroot.${clear}"
cp .htaccess web/.htaccess
echo -e "${green_bg}${white_text}Add Host to hosts.${clear}"
addhost $domain
echo -e "${green_bg}${white_text}Restarting Apache.${clear}"
sudo apachectl stop
sudo apachectl start
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment