0byt3m1n1
Path:
/
data
/
applications
/
aps
/
typo3
/
12.4.7
/
scripts
/
[
Home
]
File: typo3_aps.sh
#!/bin/bash # Global variables, modify as needed (non read-only) APP_NAME="typo3" PREV_APS_VERSION="4.5.5-0" # Previous APS version installed APS_VERSION="12.4" # latest APS official version APS_RELEASE=7 readonly APS_FULL_VERSION="$APS_VERSION.$APS_RELEASE" APS_DOWNLOAD_URL="https://get.typo3.org/$APS_FULL_VERSION" # latest APS official version APS_ARCHIVE="$APP_NAME-$APS_FULL_VERSION.tar.gz" CUSTOM_APP_DIR= # if used, don't forget to end it with a "/" (without the double quotes) readonly APS_HOME="/data/applications/aps/$APP_NAME" PREV_APP_SCRIPTS_DIR=$PREV_APS_VERSION/standard/scripts NEW_APP_SCRIPTS_DIR=$APS_FULL_VERSION/standard/scripts NEW_APP_HTDOCS_DIR=$APS_FULL_VERSION/standard/htdocs function restore_color { echo -n -e "\e[0m" } function print_ok { show_cursor kill -STOP $! &> /dev/null echo -e "\e[1;32mOK" restore_color } function print_error { show_cursor kill -STOP $! &> /dev/null echo -e "\e[1;31mERROR" restore_color echo -e "\nPlease take a look at the $APP_NAME.log file to find out what went wrong.\n" } function print_status { if [ $? -ne 0 ] then print_error exit $? fi if [ $# -eq 0 ] then print_ok fi } function hide_cursor { echo -ne "\e[?25l" } function show_cursor { echo -ne "\e[?25h" } function show_progress { local CHARS='|/-\' if [ $! ] then hide_cursor kill -CONT $! return fi while true do CHARS="${CHARS#?}${CHARS%???}" printf "\e[1;34m%.1s\b" $CHARS restore_color sleep 1 done } function ask_reinstall { echo -n "Do you want to reinstall [Y/n]? " read -n 1 ANSWER ANSWER=`echo $ANSWER | tr '[:upper:]' '[:lower:]'` if [ "$ANSWER" = "n" ] then echo -e "\n" exit 1 fi if [ -z $ANSWER ] || [ "$ANSWER" = "y" ] then echo -en "\nRemoving $APP_NAME v$APS_FULL_VERSION installation directory: " show_progress rm -rf $APS_HOME/$APS_FULL_VERSION >> $APP_NAME.log 2>&1 if [ $? -ne 0 ] then print_error false echo -e "\nCan't remove $APP_NAME v$APS_FULL_VERSION installation directory." echo -e "Please make sure you're running this script as the root user.\n" exit 2 fi print_ok else echo ask_reinstall fi } # # Common steps for all OSS Apps # echo show_progress & trap "show_cursor; kill $!" EXIT kill -STOP $! > $APP_NAME.log if [ -d $APS_HOME/$APS_FULL_VERSION ] then echo -e "$APP_NAME v$APS_FULL_VERSION APS package already installed.\n" ask_reinstall fi if [ -a $APS_ARCHIVE ] then echo -n "Deleting old $APP_NAME APS download: " show_progress rm -f $APS_ARCHIVE >> $APP_NAME.log 2>&1 print_status fi # Download APS echo -n "Downloading $APP_NAME APS v$APS_FULL_VERSION: " show_progress wget "$APS_DOWNLOAD_URL/" -O $APS_ARCHIVE >> $APP_NAME.log 2>&1 if ! [ -a $APS_ARCHIVE ] then # just in case... false fi print_status if [ -d $APS_FULL_VERSION ] then echo -n "Deleting old $APP_NAME APS directory: " show_progress rm -rf $APS_FULL_VERSION >> $APP_NAME.log 2>&1 print_status fi if [ -d $APS_FULL_VERSION ] then echo -n "Deleting old $APP_NAME directory: " show_progress rm -rf $APS_FULL_VERSION >> $APP_NAME.log 2>&1 print_status fi # Create htdocs output directory mkdir -p $NEW_APP_HTDOCS_DIR # Uncompress App archive echo -n "Uncompressing $APP_NAME archive: " show_progress ARCHIVE_EXTENSION=`echo ${APS_ARCHIVE##*.} | tr '[:upper:]' '[:lower:]'` case $ARCHIVE_EXTENSION in "gz" ) CMD="tar zxf $APS_ARCHIVE " DIR1=`tar tf $APS_ARCHIVE | head -1 | cut -d / -f 1` DIR2=`tar tf $APS_ARCHIVE | tail -1 | cut -d / -f 1` ;; "bz2" ) CMD="tar jxf $APS_ARCHIVE " DIR1=`tar tf $APS_ARCHIVE | head -1 | cut -d / -f 1` DIR2=`tar tf $APS_ARCHIVE | tail -1 | cut -d / -f 1` ;; "zip" ) CMD="unzip $APP_ARCHIVE" DIR1=`unzip -l $APP_ARCHIVE | head -4 | tail -1 | tr -s '[:blank:]' | cut -d " " -f 5 | cut -d / -f 1` DIR2=`unzip -l $APP_ARCHIVE | tail -3 | head -1 | tr -s '[:blank:]' | cut -d " " -f 5 | cut -d / -f 1` ;; * ) echo -e "\nUnknown archive format for: $APS_ARCHIVE\n" >> $APP_NAME.log 2>&1 false print_status ;; esac if [ "$DIR1" == "$DIR2" ] then $CMD >> $APP_NAME.log 2>&1 print_status false mv -f $DIR1/* $NEW_APP_HTDOCS_DIR >> $APP_NAME.log 2>&1 else if [ $ARCHIVE_EXTENSION = "zip" ] then CMD="$CMD -d $NEW_APP_HTDOCS_DIR" else CMD="$CMD -C $NEW_APP_HTDOCS_DIR" fi $CMD >> $APP_NAME.log 2>&1 fi print_status # Create typo3 symlink in bin directory mkdir -p $NEW_APP_HTDOCS_DIR/bin cd $NEW_APP_HTDOCS_DIR/bin ln -s ../vendor/typo3/cms-cli/typo3 cd $OLDPWD # Copy script files for PCP management echo -n "Copying script files: " show_progress mkdir -p $NEW_APP_SCRIPTS_DIR >> $APP_NAME.log 2>&1 cp -f /data/applications/aps/$APP_NAME/$PREV_APP_SCRIPTS_DIR/* $NEW_APP_SCRIPTS_DIR >> $APP_NAME.log 2>&1 print_status # install new APS echo -n "Installing new $APP_NAME APS: " show_progress rm -f $APS_ARCHIVE >> $APP_NAME.log 2>&1 chown -R root:root $APS_FULL_VERSION >> $APP_NAME.log 2>&1 if ! [ -d $APS_HOME ] then mkdir $APS_HOME >> $APP_NAME.log 2>&1 print_status false fi mv -f $APS_FULL_VERSION $APS_HOME >> $APP_NAME.log 2>&1 print_status # Everything went well! echo -e "\nSuccesfully created and installed $APP_NAME v$APS_FULL_VERSION APS package!\n" echo "Upgrading Typo3 to $WP_VER in iqdb..."; if [ -f $APS_HOME/$NEW_APP_HTDOCS_DIR/bin/typo3 ] then perl /var/tmp/platform-aps/typo3/aps-typo3/scripts/upgrade_typo_vux.pl $APS_FULL_VERSION echo "Typo3 for VUX has been upgraded to $APS_FULL_VERSION in IQDB!"; fi