echo ">> Welcom to the SKNKWOXS project set up spcript."
echo -e ">> This script will set up a basic project structure, staging git repository, and password protection.\n"
echo ">> This script assumes you are cloning from Sknkwoxs Github Account."
echo ">> Please enter the repository name."
echo -e ">> It will be used for the project and htaccess username.\n"
echo ">> Repository Name:"
echo -e ">> Begin setup...\n"
# Create the repo directory
git clone --bare --shared git@github.com:sknkwoxs/$name.git $name.git
echo -e ">> Git post receive hook is set up at ~/repos/$name.git \n"
echo -e ">> Cloning repository...\n"
git --work-tree="/var/www/$name" --git-dir="/home/sknk/repos/$name.git" checkout -f $git_branch
# Create hook post-receive
cat > hooks/post-receive << EOF
# the work tree, where the checkout/deploy should happen
# the location of the .git directory
GIT_DIR="/home/sknk/repos/$name.git"
while read oldrev newrev ref
# only checking out the master (or whatever branch you would like to deploy)
if [ "\${ref}" = "refs/heads/\${BRANCH}" ];
echo "Ref \${ref} received. Deploying \${BRANCH} branch on server..."
git --work-tree="\${TARGET}" --git-dir="\${GIT_DIR}" checkout -f \${BRANCH}
cd \${TARGET} && ddev composer install -o --no-dev
echo "Ref \${ref} received. Doing nothing: only the \${BRANCH} branch may be deployed on this server."
chmod +x hooks/post-receive
if [ -d "/var/www/$name/.ddev" ]; then
echo -e ">> DDEV start ..."
echo -e ">> If snapshot exiest, please select db file that you want to restore..."
echo -e ">> Create ddev config"
#echo -e ">> DDEV start ..."
# Execute composer install
if [ -f "/var/www/$name/composer.json" ]; then
echo -e ">> composer.json exists."
ddev composer install -o --no-dev