Skip to content

Instantly share code, notes, and snippets.

@CyberPunkCodes
Created September 21, 2018 04:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CyberPunkCodes/32b24ed1732699d41b2cfe1ed717ec79 to your computer and use it in GitHub Desktop.
Save CyberPunkCodes/32b24ed1732699d41b2cfe1ed717ec79 to your computer and use it in GitHub Desktop.
#!/bin/sh
CPANEL_USERNAME=YOURUSERNAME
APP_NAME=YOURAPPNAME # ".git" will be added and should match your bare repo filename
APP_DIR="public_html/prod" # include "public_html", do not start with forward slash!
HOMEDIR="/home/$CPANEL_USERNAME"
PHP="php -d allow_url_fopen=1 -d memory_limit=256M -d suhosin.executor.include.whitelist=phar"
COMPOSER="$PHP $HOMEDIR/bin/composer.phar"
#################################################
########## DO NOT EDIT BELOW THIS LINE ##########
#################################################
# Set up our PATH variable and export it
PATH=$HOMEDIR/bin:$PATH
export PATH
# App directories
APP_GIT_DIR="$HOMEDIR/git/$APP_NAME.git"
APP_WEB_DIR="$HOMEDIR/$APP_DIR"
if [ ! -d $APP_GIT_DIR ]
then
printf "Git bare repo not found at: $APP_GIT_DIR"
exit 1
fi
if [ ! -d $APP_WEB_DIR ]
then
printf "Web directory not found at: $APP_WEB_DIR"
exit 1
fi
# Checkout the last commit inside the web app directory
git --work-tree=${APP_WEB_DIR} --git-dir=${APP_GIT_DIR} checkout -f
# WARNING: Un-commenting/Enabling this will delete all files on every push
# and essetially reset your web dir to match your git archive.
#
# Reset/Clean the app directory
# Use -e "[pattern]" to exclude some file or directory to be cleaned,
# as they are in the .gitignore file
#
# git --work-tree=${APP_WEB_DIR} clean -fd
# Run composer
cd ${APP_WEB_DIR}
#$COMPOSER install --no-dev --no-scripts
printf "\n\nComposer does not work on this web host!\nPlease manually upload vendor directory.\n\n"
if [ ! -d $APP_WEB_DIR/vendor ]
then
printf "Vendor directory not found at: $APP_WEB_DIR/vendor\n"
exit 2
fi
if [ -e $APP_WEB_DIR/yii ] && [ -e $APP_WEB_DIR/init ]
then
printf "Yii2 Application Detected!\n\n"
chmod +x yii
chmod +x init
if [ ! -x $APP_WEB_DIR/init ]
then
printf "$APP_WEB_DIR/init file does not have execute permission!\n"
exit 3
fi
if [ ! -x $APP_WEB_DIR/yii ]
then
printf "$APP_WEB_DIR/yii file does not have execute permission!\n"
exit 3
fi
# init yii2 environment
$PHP init --env=Production --overwrite=All
# run migrations
$PHP yii migrate --interactive=0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment