#!/bin/bash ###----------------------------------------### ### ### Octopus Aegir Installer ### ### Copyright (C) 2010-2014 Omega8.cc ### noc@omega8.cc www.omega8.cc ### ### This program is free software. You can ### redistribute it and/or modify it under ### the terms of the GNU GPL as published by ### the Free Software Foundation, version 2 ### or later. ### ### This program is distributed in the hope ### that it will be useful, but WITHOUT ANY ### WARRANTY; without even the implied ### warranty of MERCHANTABILITY or FITNESS ### FOR A PARTICULAR PURPOSE. See the GNU GPL ### for more details. ### ### You should have received a copy of the ### GNU GPL along with this program. ### If not, see http://www.gnu.org/licenses/ ### ### Code: https://code.aegir.cc/aegir ### ###----------------------------------------### ###----------------------------------------### ### HOW-TO: run it with bash, not with sh ### ###----------------------------------------### ### ### $ bash OCTOPUS.sh.txt ### ###----------------------------------------### ### EDITME ### ###----------------------------------------### ### ### Enter below your valid e-mail address and ### the (sub)domain for this Aegir Satellite ### Instance, already pointing to your server. ### Define also your *new* Aegir user for this ### instance or existing if this is an upgrade ### ### NOTE: if this is an upgrade, it's enough ### to define the _USER value only, since ### _DOMAIN etc. will be auto-discovered ### and you can't override it here nor even ### in the /root/.${_USER}.octopus.cnf file. ### _USER=o1 _DOMAIN=$_USER.`uname -n` _MY_EMAIL="noc@omega8.cc" _CLIENT_EMAIL="notify@omega8.cc" _CLIENT_OPTION=SSD _CLIENT_SUBSCR=Y _CLIENT_CORES=8 ###----------------------------------------### ### EASY LOCALHOST MODE ### ###----------------------------------------### ### ### This option is available and enabled ### automatically only when Barracuda has been ### installed with option _EASY_LOCALHOST=YES ### ### It will automate/force only some of other ### Octopus configuration options, as listed ### below: ### ### _PHP_FPM_VERSION=5.3 ### _PHP_CLI_VERSION=5.3 ### _DEBUG_MODE=NO ### _AEGIR_VERSION=HEAD ### _DNS_SETUP_TEST=NO ### _THIS_DB_HOST=localhost ### _LOCAL_NETWORK_IP="127.0.1.1" ### _DOMAIN=$_USER.sub.aegir.local ### ### Thanks to local DNS wildcard, you will be ### able to use many levels of subdomains for ### created sites, for example: ### site.aegir.local, abc.xyz.site.aegir.local ### This wildcard will rely only on the local, ### basic DNS system, without any need to use ### external DNS. ### ###----------------------------------------### ### PHP-FPM VERSION ### ###----------------------------------------### ### ### You can choose PHP-FPM version per Aegir ### Satellite Instance - both on install and ### upgrade. ### ### Available options (if installed): ### ### _PHP_FPM_VERSION=5.5 ### _PHP_FPM_VERSION=5.4 ### _PHP_FPM_VERSION=5.3 ### _PHP_FPM_VERSION=5.2 ### ### Note that 5.3 will be set automatically ### if you specify any other, not installed ### version. ### _PHP_FPM_VERSION=5.3 ###----------------------------------------### ### PHP-CLI VERSION ### ###----------------------------------------### ### ### You can choose PHP-CLI version per Aegir ### Satellite Instance - both on install and ### upgrade. ### ### Available options (if installed): ### ### _PHP_CLI_VERSION=5.5 ### _PHP_CLI_VERSION=5.4 ### _PHP_CLI_VERSION=5.3 ### _PHP_CLI_VERSION=5.2 ### ### Note that 5.3 will be set automatically ### if you specify any other, not installed ### version. ### _PHP_CLI_VERSION=5.3 ###----------------------------------------### ### PLATFORMS INSTALL MODE ### ###----------------------------------------### ### ### You can use wildcard "ALL" to install all ### available platforms or configure the list ### of platforms to be installed as explained ### below. ### ### Note: the "ALL" wildcard is not default! ### ### When combined with _AUTOPILOT=YES option ### you can speed up the process and still ### control which platforms will be installed, ### using the symbols listed below. ### ### D8D ----------- Drupal 8 dev-tested (off) ### D8E ----------- Drupal 8 dev-edge (off) ### D7P D7S D7D --- Drupal 7 prod/stage/dev ### D6P D6S D6D --- Pressflow 6 p/s/d ### AGV ----------- aGov ### AQ6 ----------- Acquia D6 (off) ### CM6 ----------- CiviCRM 4.1.6 D6 (off) ### CM7 ----------- CiviCRM 4.3.7 D7 (off) ### CME ----------- Commerce v.2 ### COD ----------- Conference (off) ### CS7 ----------- Commons 7 ### DCE ----------- Commerce v.1 ### DCS ----------- Commons 6 ### ERP ----------- ERPAL ### FSR ----------- Feature Server ### GDR ----------- Guardr ### MNS ----------- Managing News ### NS7 ----------- NodeStream D7 (off) ### OA7 ----------- Open Atrium D7 ### OAM ----------- Open Atrium D6 ### OAY ----------- Open Academy ### OBG ----------- OpenBlog ### OCH ----------- OpenChurch ### ODS ----------- Open Deals ### OOH ----------- Open Outreach ### OPH ----------- OpenPublish (off) ### OSR ----------- OpenScholar ### PPT ----------- ProsePoint (off) ### PPY ----------- Panopoly ### RER ----------- Recruiter ### RST ----------- Restaurant ### SRK ----------- Spark ### TTM ----------- Totem ### UC7 ----------- Ubercart D7 ### UCT ----------- Ubercart D6 ### ### Examples: ### ### _PLATFORMS_LIST=ALL ### _PLATFORMS_LIST="D7P D6P OAM MNS NS7 OOH" ### _PLATFORMS_LIST="D7P D7S D7D D6P D6S D6D" ###----------------------------------------### ### UNSUPPORTED (off) DISTROS INSTALL ### ###----------------------------------------### ### ### If you wish to install also distros listed ### above as (off), change the option below ### to: _ALLOW_UNSUPPORTED=YES ### ### Note that this option works only with BOA ### HEAD and not stable version. ### _ALLOW_UNSUPPORTED=NO ###----------------------------------------### ### AUTOPILOT MODE ### ###----------------------------------------### ### ### To disable all Yes/no prompts and just run ### everything as-is, change this to YES. ### ### _AUTOPILOT=YES ### _AUTOPILOT=NO ###----------------------------------------### ### UPGRADE MODE ### ###----------------------------------------### ### ### To upgrade Hostmaster without installing ### new platforms, change this to YES. ### ### Don't use this option for initial install. ### ### _HM_ONLY=YES ### _HM_ONLY=NO ###----------------------------------------### ### O_CONTRIB UPGRADE ### ###----------------------------------------### ### ### To upgrade o_contrib modules in the latest ### and one previous platforms series 00x ### change this to YES. ### ### This option is available only on Aegir ### Satellite Instance upgrade. ### ### _O_CONTRIB_UP=YES ### _O_CONTRIB_UP=NO ###----------------------------------------### ### DRUSH DEBUG MODE ### ###----------------------------------------### ### ### When set to YES it will run this Satellite ### Instance install/upgrade with -d option, ### displaying complete Drush backend report. ### ### _DEBUG_MODE=YES ### _DEBUG_MODE=NO ###----------------------------------------### ### FORCED IP MODE ### ###----------------------------------------### ### ### To install or upgrade Aegir Satellite ### Instance on any non-default IP address ### available on your server/machine, please ### define it below. For default, main IP ### based install, leave this empty. ### ### _MY_OWNIP=123.45.67.89 ### _MY_OWNIP="" ###----------------------------------------### ### AEGIR BARRACUDA VERSION ### ###----------------------------------------### ### ### By default latest release version will ### be installed. Please never use HEAD (dev) ### version on any production server. ### The HEAD can be occasionally broken ### and should be used **only** for testing! ### ### _AEGIR_VERSION=HEAD ### _AEGIR_VERSION=BOA-2.2.5 ### _AEGIR_VERSION=HEAD ###----------------------------------------### ### FORCE PREFERRED GIT REPOSITORY ### ###----------------------------------------### ### ### Use this when you are experiencing issues ### trying to connect to the default github ### repository. Valid options: ### ### _FORCE_GIT_MIRROR=github ### _FORCE_GIT_MIRROR=drupal ### _FORCE_GIT_MIRROR=gitorious ### ### Note: with forced mirror the script will ### not try to connect and then switch to ### alternate mirror. It will simply fail ### if the forced mirror doesn't respond. ### ### We recommend github as it is much faster, ### often 10x than drupal and gitorious. ### _FORCE_GIT_MIRROR="" ###----------------------------------------### ### DNS SETUP TEST ### ###----------------------------------------### ### ### If you don't want to test your DNS ### because of some custom local setup ### you know is correct (like DynDNS) ### but the script can't validate it with its ### standard ifconfig tests, set this to: ### ### _DNS_SETUP_TEST=NO ### ### There is no guarantee it will work. ### _DNS_SETUP_TEST=YES ###----------------------------------------### ### DATABASE CUSTOM HOST ### ###----------------------------------------### ### ### If you prefer, you can set the database ### to be connected via FQDN pointing to your ### public IP instead of default "localhost". ### ### Note: the "FQDN" is a keyword. ### Don't replace it with a real hostname. ### ### For local or Amazon based installs with ### local/dynamic IP address it is recommended ### to use default "localhost" option. ### ### Available options: ### ### _THIS_DB_HOST=localhost ### _THIS_DB_HOST=FQDN ### _THIS_DB_HOST=localhost ###----------------------------------------### ### DISTRO INITIAL VERSION NR ### ###----------------------------------------### ### ### By default every new Aegir Satellite ### Instance will use shared code for its ### platforms, created during previous Aegir ### Satellite Instance install or upgrade, ### resulting with new 00x number in the ### /data/all directory. ### ### It is not always good, since you want ### to keep the code shared between instances, ### but you also don't want to create a new ### instance with outdated code if your last ### install/upgrade was performed a few months ### ago. ### ### If you don't want to build a new Aegir ### Satellite Instance with latest code, then ### leave it at default value. Otherwise ### change it to: ### ### _HOT_SAUCE=YES ### _HOT_SAUCE=NO ###----------------------------------------### ### DISTRO USING EXISTING VERSION NR ### ###----------------------------------------### ### ### We changed the default to YES to avoid ### creating many duplicated platforms on ### every Aegir Satellite Instance upgrade, ### when there is no new core, thus no reason ### to create newer platforms for the same ### distributions versions. ### ### It will also allow you to add some newer ### platforms to the existing shared code, ### which helps to keep your opcache memory ### as low as possible without fragmentation. ### ### When set to _USE_CURRENT=NO it will force ### creating new set (with increased serial ### number) of *all* platforms on upgrade, ### so it is useful *only* when there is ### a newer Drupal core version released, or ### when newer Pressflow head includes some ### important fixes. ### ### Note: it will not work at all if you are ### using _HOT_SAUCE=YES above, because ### _HOT_SAUCE=YES forces new serial number ### both on install and upgrade. ### _USE_CURRENT=YES ###----------------------------------------### ### DELETE OLD EMPTY PLATFORMS ### ###----------------------------------------### ### ### Change to any integer greater than "0" to ### automatically delete empty platforms with ### no sites hosted, during daily cleanup, ### if verified more than X days ago, where X ### is a number of days defined below. ### If "0" then this option is disabled. ### _DEL_OLD_EMPTY_PLATFORMS="0" ###----------------------------------------### ### DELETE OLD BACKUPS ### ###----------------------------------------### ### ### Change to any integer greater than "0" to ### automatically delete backups stored in the ### /data/disk/U/backups/ directory and in all ### hosted sites backup_migrate directories, ### during daily cleanup, if created more ### than X days ago, where X is a number ### of days defined below. If "0" then ### this option is disabled. ### _DEL_OLD_BACKUPS="0" ###----------------------------------------### ### DELETE OLD TMP FILES ### ###----------------------------------------### ### ### Change to any integer greater than "0" to ### automatically delete temporary files ### in all hosted sites files/tmp/ and also ### private/temp/ directories, during daily ### cleanup, if created more than X days ago, ### where X is a number of days defined below. ### If "0" then this option is disabled. ### _DEL_OLD_TMP="0" ###----------------------------------------### ### LOCALHOST ON LOCAL NETWORK ### ###----------------------------------------### ### ### When enabled, it will force your Nginx web ### server to listen only on local IP: ### ### _LOCAL_NETWORK_IP=10.10.80.80 ### ### This option is useful when your server is ### available only in your local network ### without any public IP address assigned/ ### available on any eth interface. This also ### means it should work as a handy local ### setup on your wirelessly connected laptop ### or netbook, with improved DNS cache ### support - pdnsd will save results in file. ### ### In this case you could use 127.0.1.1 as ### _LOCAL_NETWORK_IP to avoid issues with ### DHCP changing your assigned IP on the fly ### and to avoid conflicts with some other ### services listening on 127.0.0.1 ### ### This option works only with initial ### install and is disabled on upgrade. ### ### You should use this option only when you ### already used it with initial Barracuda ### install. It will override any defined ### above _MY_OWNIP value and disable DNS test ### automatically. ### _LOCAL_NETWORK_IP="" ###----------------------------------------### ### STOCK AEGIR TESTING ### ###----------------------------------------### ### ### Change to YES to try Stock Aegir 2.x with ### Drush 5.x - without any BOA specific ### modifications or improvements. This option ### is enabled on command line when you type ### "stock" instead of "mini", "max" or "ask". ### _USE_STOCK=NO ###----------------------------------------### ### STRONG PASSWORDS ### ###----------------------------------------### ### ### Use YES only if both "randpass 32 esc" ### and "randpass 32 alnum" commands produce ### well looking, strong passwords and not ### some binary garbage, which is typically ### a sign of unreliable /dev/urandom. ### See: https://drupal.org/node/1952042 ### ### By default new passwords are generated ### with "pwgen -v -s -1" command. ### _STRONG_PASSWORDS=NO ###----------------------------------------### ### DB ENGINE AUTO-CONVERSION ### ###----------------------------------------### ### ### Automatic, running daily DB conversion to ### InnoDB or MyISAM for all sites hosted on ### the instance via the 'sqlmagic' tool. ### ### If _SQL_CONVERT=NO is set, the conversion ### mode can be individually enabled and more ### precisely configured with variable: ### ### sql_conversion_mode ### ### if set in the site and/or platform level, ### active INI files: ### ### boa_platform_control.ini ### boa_site_control.ini ### ### More info: https://omega8.cc/node/293 ### ### Please note that if you will change it ### to _SQL_CONVERT=YES, the system will ### ignore sql_conversion_mode variables set ### in the active INI files, and instead will ### force conversion to InnoDB format in all ### sites hosted on this instance. ### ### Note that it will run daily on all sites ### even if all tables have been already ### converted to the desired format/engine. ### ### This behaviour has two purposes. It will ### effectively run OPTIMIZE foo; on all, ### even already converted tables via the ### ALTER TABLE foo ENGINE=bar; command. ### It will also make sure that any newly ### created table will receive expected ### format/engine, despite system or Drupal ### core defaults. ### ### Accepted values: ### ### innodb (forced globally) ### myisam (forced globally) ### YES (same as innodb, forced globally) ### NO (nothing forced globally) ### _SQL_CONVERT=NO ###----------------------------------------### ### ADVANCED CONFIGURATION OPTIONS ### ###----------------------------------------### ### ### AUTO will default to value calculated ### on the fly and based on available RAM. ### You can force workers number for PHP-FPM. ### _PHP_FPM_WORKERS=AUTO ### ### AUTO will not modify default TTL (180). ### You can lower it to any number < 180. ### _PHP_FPM_TIMEOUT=AUTO ### ### You can define custom list of functions ### to disable besides those already denied ### in the system level 'disable_functions'. ### ### Note: If this option is left empty, BOA ### will deny access also to function: ### ### passthru ### ### If _PHP_FPM_DENY is *not* empty, its value ### will *replace* 'passthru', so any denied ### function must be listed explicitly. ### ### Note that while it will improve security ### it will also break modules which rely ### on any of disabled functions. ### ### This option affects only this Satellite ### Instance. It is not affected by the same ### option set in the Barracuda Master. ### ### Example: ### ### _PHP_FPM_DENY="system,exec,shell_exec" ### _PHP_FPM_DENY="" ### ### Define the amount of RAM you want to keep ### reserved for other services installed which ### are not controlled by BOA, so it will ### assume that available RAM is the value of ### $_RAM - $_RESERVED_RAM (in MB). ### ### Example for 256MB: _RESERVED_RAM=256 ### _RESERVED_RAM=0 ###----------------------------------------### ### DON'T EDIT ANYTHING BELOW THIS LINE ### ###----------------------------------------### _INSTALLER_VERSION=BOA-2.2.6-dev ### ### Variables ### _DRUSH_VERSION=mini-4-14-03-2014 _NOW=`date +%y%m%d-%H%M` _PLATFORMS_ONLY=NO _PURGE_FOR_SEVEN=YES _SMALLCORE6=6.31.2 _SMALLCORE7=7.28.1 _SMALLCORE8=8.0-alpha4 _SPINNER=YES _T_BUILD=HEAD _TODAY=`date +%y%m%d` _USRG=users _WEBG=www-data PATH=/usr/local/bin:/usr/local/sbin:/opt/local/bin:/usr/bin:/usr/sbin:/bin:/sbin SHELL=/bin/bash if [ -n "${STY+x}" ]; then _SPINNER=NO fi if [ "$_USE_STOCK" = "YES" ] ; then _DRUSH_VERSION=mini-6-31-05-2014 fi ### ### Distributions ### _AGOV=7.x-1.0-rc8 _CIVICRM_M6=4.1.6 _CIVICRM_M7=4.3.7 _CIVICRM_PN=boa-2.0.9-dev _COD=7.x-1.0-alpha5 _COMMERCE1=7.x-1.25 _COMMERCE2=7.x-2.15 _COMMONS2=6.x-2.17 _COMMONS3=7.x-3.13 _DRUPAL_EDGE_8="8.0-dev-$_TODAY-edge" _DRUPAL7="drupal-$_SMALLCORE7" _DRUPAL8="8.0-dev-120915" _ERPAL=7.x-2.0-beta2 _GUARDR=7.x-1.4 _MANAGINGNEWS=1.2.4 _NODESTREAM7=7.x-2.0-rc5 _OPEN_DEALS=1.32 _OPENACADEMY=7.x-1.0 _OPENATRIUM6=6.x-1.7 _OPENATRIUM7=7.x-2.19 _OPENBLOG=7.x-1.0-alpha2 _OPENCHURCH=7.x-1.12 _OPENDEALS=7.x-1.32 _OPENOUTREACH=7.x-1.7 _OPENPUBLISH=7.x-1.0-beta7 _OPENSCHOLAR=7.x-3.12.1 _PANOPOLY=7.x-1.6 _PROSEPOINT=0.46 _RECRUITER=7.x-1.2 _RESTAURANT=7.x-1.0-alpha5 _SPARK=7.x-1.0-beta1 _TOTEM=7.x-1.1 _UBERCART6=2.13 _UBERCART7=3.6 ###---### Functions # # Noticeable messages. msg () { echo "Octopus [`date`] ==> $*" } # Simple prompt. prompt_yes_no () { if [ "$_AUTOPILOT" = "YES" ] ; then return 0 else while true ; do printf "$* [Y/n] " read answer if [ -z "$answer" ] ; then return 0 fi case $answer in [Yy]|[Yy][Ee][Ss]) return 0 ;; [Nn]|[Nn][Oo]) return 1 ;; *) echo "Please answer yes or no" ;; esac done fi } # # Small spinner. mrun () { CMD="$1" touch busy if [ "$_SPINNER" = "YES" ] ; then bash $_SRCDIR/spinner busy & fi if $CMD >> $_LOG; then rm busy sleep 1 return 0 fi } # # Tune FPM workers. tune_fpm_workers () { _ETH_TEST=`ifconfig 2>&1` _VM_TEST=`uname -a 2>&1` if [[ "$_ETH_TEST" =~ "venet0" ]] ; then _VMFAMILY="VZ" elif [ -e "/proc/bean_counters" ] ; then _VMFAMILY="VZ" elif [[ "$_THISHOST" =~ ".host8." ]] && [ -e "/boot/grub/menu.lst" ] ; then _VMFAMILY="TG" elif [[ "$_THISHOST" =~ ".host8." ]] && [ -e "/boot/grub/grub.cfg" ] ; then _VMFAMILY="TG" else _VMFAMILY="XEN" fi if [[ "$_VM_TEST" =~ beng ]] ; then _VMFAMILY="VS" fi if [[ "$_AWS_TEST_A" =~ "cloudimg" ]] || [[ "$_AWS_TEST_B" =~ "cloudconfig" ]] ; then _VMFAMILY="AWS" fi _RAM=`free -mto | grep Mem: | awk '{ print $2 }'` if [ "$_RESERVED_RAM" -gt "0" ] ; then let "_RAM = (($_RAM - $_RESERVED_RAM))" fi let "_USE = (($_RAM / 4))" if [ "$_USE" -ge "512" ] && [ "$_USE" -lt "1024" ] ; then if [ "$_PHP_FPM_WORKERS" = "AUTO" ] ; then _L_PHP_FPM_WORKERS=12 else _L_PHP_FPM_WORKERS=$_PHP_FPM_WORKERS fi elif [ "$_USE" -ge "1024" ] ; then if [ "$_VMFAMILY" = "XEN" ] || [ "$_VMFAMILY" = "AWS" ] ; then if [ "$_PHP_FPM_WORKERS" = "AUTO" ] ; then _L_PHP_FPM_WORKERS=24 else _L_PHP_FPM_WORKERS=$_PHP_FPM_WORKERS fi elif [ "$_VMFAMILY" = "VS" ] || [ "$_VMFAMILY" = "TG" ] ; then if [ -e "/boot/grub/grub.cfg" ] || [ -e "/boot/grub/menu.lst" ] || [ -e "/root/.tg.cnf" ] ; then if [ "$_PHP_FPM_WORKERS" = "AUTO" ] ; then _L_PHP_FPM_WORKERS=24 else _L_PHP_FPM_WORKERS=$_PHP_FPM_WORKERS fi else if [ "$_PHP_FPM_WORKERS" = "AUTO" ] ; then _L_PHP_FPM_WORKERS=6 else _L_PHP_FPM_WORKERS=$_PHP_FPM_WORKERS fi fi else if [ "$_PHP_FPM_WORKERS" = "AUTO" ] ; then _L_PHP_FPM_WORKERS=12 else _L_PHP_FPM_WORKERS=$_PHP_FPM_WORKERS fi fi else if [ "$_PHP_FPM_WORKERS" = "AUTO" ] ; then _L_PHP_FPM_WORKERS=6 else _L_PHP_FPM_WORKERS=$_PHP_FPM_WORKERS fi fi } # # Tune FPM configuration. tune_fpm_config () { tune_fpm_workers _LIM_FPM="$_L_PHP_FPM_WORKERS" if [ "$_LIM_FPM" -lt "24" ] ; then if [[ "$_THISHOST" =~ ".host8." ]] || [ "$_VMFAMILY" = "VS" ] ; then _LIM_FPM=24 fi fi if [ "$_CLIENT_OPTION" = "MICRO" ] ; then _LIM_FPM=2 _PHP_FPM_WORKERS=4 fi let "_CHILD_MAX_FPM = (($_LIM_FPM * 2))" if [ "$_PHP_FPM_WORKERS" = "AUTO" ] ; then _DO_NOTHING=YES else _PHP_FPM_WORKERS=${_PHP_FPM_WORKERS//[^0-9]/} if [ ! -z "$_PHP_FPM_WORKERS" ] && [ "$_PHP_FPM_WORKERS" -gt "0" ] ; then _CHILD_MAX_FPM="$_PHP_FPM_WORKERS" fi fi _PHP_SV=${_PHP_FPM_VERSION//[^0-9]/} if [ -z "$_PHP_SV" ] ; then _PHP_SV=53 fi if [ -e "/opt/php55/etc/pool.d/${_USER}.conf" ] ; then _PHP_OLD_SV=55 elif [ -e "/opt/php54/etc/pool.d/${_USER}.conf" ] ; then _PHP_OLD_SV=54 elif [ -e "/opt/php53/etc/pool.d/${_USER}.conf" ] ; then _PHP_OLD_SV=53 else _PHP_OLD_SV="" fi if [ "$_PHP_FPM_TIMEOUT" = "AUTO" ] || [ -z "$_PHP_FPM_TIMEOUT" ] ; then _PHP_FPM_TIMEOUT=180 fi _PHP_FPM_TIMEOUT=${_PHP_FPM_TIMEOUT//[^0-9]/} if [ "$_PHP_FPM_TIMEOUT" -lt "60" ] ; then _PHP_FPM_TIMEOUT=60 fi if [ ! -e "/var/xdrago/conf/fpm-pool-foo.conf" ] ; then mkdir -p /var/xdrago/conf fi cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/conf/fpm-pool-foo.conf /var/xdrago/conf/fpm-pool-foo.conf if [ ! -z "$_PHP_FPM_TIMEOUT" ] && [ ! -z "$_PHP_SV" ] ; then if [ -e "/var/xdrago/conf/fpm-pool-foo.conf" ] ; then rm -f /opt/php*/etc/pool.d/${_USER}.conf cp -af /var/xdrago/conf/fpm-pool-foo.conf /opt/php${_PHP_SV}/etc/pool.d/${_USER}.conf fi if [ -e "/opt/php${_PHP_SV}/etc/pool.d/${_USER}.conf" ] ; then sed -i "s/foo/$_USER/g" /opt/php${_PHP_SV}/etc/pool.d/${_USER}.conf &> /dev/null if [ ! -z "$_PHP_FPM_DENY" ] ; then sed -i "s/passthru,/$_PHP_FPM_DENY,/g" /opt/php${_PHP_SV}/etc/pool.d/${_USER}.conf &> /dev/null fi fi _PHP_TO="${_PHP_FPM_TIMEOUT}s" sed -i "s/180s/$_PHP_TO/g" /opt/php${_PHP_SV}/etc/pool.d/${_USER}.conf &> /dev/null if [ ! -z "$_CHILD_MAX_FPM" ] ; then sed -i "s/pm.max_children =.*/pm.max_children = $_CHILD_MAX_FPM/g" /opt/php${_PHP_SV}/etc/pool.d/${_USER}.conf &> /dev/null fi if [ ! -d "/data/disk/$_USER/tmp" ] ; then rm -f -r /data/disk/$_USER/tmp mkdir -p /data/disk/$_USER/tmp chown $_USER:www-data /data/disk/$_USER/tmp &> /dev/null fi if [ ! -z "$_PHP_OLD_SV" ] && [ -e "/etc/init.d/php${_PHP_OLD_SV}-fpm" ] ; then mrun "service php${_PHP_OLD_SV}-fpm reload" &> /dev/null fi if [ -e "/etc/init.d/php${_PHP_SV}-fpm" ] ; then mrun "service php${_PHP_SV}-fpm reload" &> /dev/null fi fi } # # Make sure that username is unique and not restricted. check_id () { _ID_EXISTS=$(getent passwd $_USER 2>&1) if [ -z "$_ID_EXISTS" ] ; then _DO_NOTHING=YES elif [[ "$_ID_EXISTS" =~ "$_USER" ]] ; then msg "ERROR: $_USER username is already taken" msg "Please choose different _USER" exit 1 else msg "ERROR: $_USER username check failed" msg "Please try different _USER" exit 1 fi if [ "$_USER" = "admin" ] || [ "$_USER" = "hostmaster" ] || [ "$_USER" = "barracuda" ] || [ "$_USER" = "octopus" ] || [ "$_USER" = "boa" ] ; then msg "ERROR: $_USER is a restricted username, please choose different _USER" exit 1 elif [[ "$_USER" =~ "drupal" ]] || [[ "$_USER" =~ "drush" ]] || [[ "$_USER" =~ "sites" ]] || [[ "$_USER" =~ "default" ]] ; then msg "ERROR: $_USER includes restricted keyword, please choose different _USER" exit 1 fi _REGEX="^[[:digit:]]" if [[ "$_USER" =~ "$_REGEX" ]] ; then msg "ERROR: $_USER is a wrong username, it should start with a letter, not digit" exit 1 fi } # # Find correct IP. find_correct_ip () { _LOC_IP=`echo $(getent ahostsv4 $_LOC_DOM) | cut -d: -f2 | awk '{ print $1}'` } # # Check repo status. check_git_repos_status () { _GITHUB_WORKS=NO _DRUPAL_WORKS=NO _GITORIOUS_WORKS=NO if [ "$_FORCE_GIT_MIRROR" = "github" ] ; then msg "INFO: We will use forced GitHub repository without testing connection" _GITHUB_WORKS=YES _DRUPAL_WORKS=NO _GITORIOUS_WORKS=NO sleep 1 elif [ "$_FORCE_GIT_MIRROR" = "drupal" ] ; then msg "INFO: We will use forced Drupal mirror without testing connection" _GITHUB_WORKS=NO _DRUPAL_WORKS=YES _GITORIOUS_WORKS=NO sleep 1 elif [ "$_FORCE_GIT_MIRROR" = "gitorious" ] ; then msg "INFO: We will use forced Gitorious mirror without testing connection" _GITHUB_WORKS=NO _DRUPAL_WORKS=NO _GITORIOUS_WORKS=YES sleep 1 else msg "INFO: Testing repository mirror servers availability..." sleep 1 _GITHUB_WORKS=YES _DRUPAL_WORKS=YES _GITORIOUS_WORKS=YES if ! netcat -w 8 -z github.com 9418 ; then _GITHUB_WORKS=NO msg "WARN: The GitHub master repository server doesn't respond..." elif ! netcat -w 8 -z git.drupal.org 80 ; then _DRUPAL_WORKS=NO msg "WARN: The Drupal mirror repository server doesn't respond..." elif ! netcat -w 8 -z code.aegir.cc 9418 ; then _GITORIOUS_WORKS=NO msg "WARN: The Gitorious mirror repository server doesn't respond..." fi fi if [ "$_GITHUB_WORKS" = "YES" ] ; then _BOA_REPO_NAME="boa" _BOA_REPO_GIT_URL="git://github.com/omega8cc" msg "INFO: GitHub master repository will be used" elif [ "$_DRUPAL_WORKS" = "YES" ] ; then _BOA_REPO_NAME="barracuda" _BOA_REPO_GIT_URL="http://git.drupal.org/project" msg "INFO: Drupal mirror repository will be used" elif [ "$_GITORIOUS_WORKS" = "YES" ] ; then _BOA_REPO_NAME="barracuda-octopus" _BOA_REPO_GIT_URL="git://code.aegir.cc/aegir" msg "INFO: Gitorious mirror repository will be used" else cat < /root/.${_USER}.octopus.cnf echo "### Configuration created on $_NOW with" >> /root/.${_USER}.octopus.cnf echo "### Octopus version $_INSTALLER_VERSION" >> /root/.${_USER}.octopus.cnf echo "###" >> /root/.${_USER}.octopus.cnf echo "### NOTE: the group of settings displayed bellow" >> /root/.${_USER}.octopus.cnf echo "### will *override* all listed settings in the Octopus script." >> /root/.${_USER}.octopus.cnf echo "###" >> /root/.${_USER}.octopus.cnf echo "_USER=\"$_USER\"" >> /root/.${_USER}.octopus.cnf echo "_MY_EMAIL=\"$_MY_EMAIL\"" >> /root/.${_USER}.octopus.cnf echo "_PLATFORMS_LIST=\"$_PLATFORMS_LIST\"" >> /root/.${_USER}.octopus.cnf echo "_ALLOW_UNSUPPORTED=$_ALLOW_UNSUPPORTED" >> /root/.${_USER}.octopus.cnf echo "_AUTOPILOT=$_AUTOPILOT" >> /root/.${_USER}.octopus.cnf echo "_HM_ONLY=$_HM_ONLY" >> /root/.${_USER}.octopus.cnf echo "_O_CONTRIB_UP=$_O_CONTRIB_UP" >> /root/.${_USER}.octopus.cnf echo "_DEBUG_MODE=$_DEBUG_MODE" >> /root/.${_USER}.octopus.cnf echo "_MY_OWNIP=$_MY_OWNIP" >> /root/.${_USER}.octopus.cnf echo "_FORCE_GIT_MIRROR=\"$_FORCE_GIT_MIRROR\"" >> /root/.${_USER}.octopus.cnf echo "_THIS_DB_HOST=$_THIS_DB_HOST" >> /root/.${_USER}.octopus.cnf echo "_DNS_SETUP_TEST=$_DNS_SETUP_TEST" >> /root/.${_USER}.octopus.cnf echo "_HOT_SAUCE=$_HOT_SAUCE" >> /root/.${_USER}.octopus.cnf echo "_USE_CURRENT=$_USE_CURRENT" >> /root/.${_USER}.octopus.cnf echo "_DEL_OLD_EMPTY_PLATFORMS=$_DEL_OLD_EMPTY_PLATFORMS" >> /root/.${_USER}.octopus.cnf echo "_DEL_OLD_BACKUPS=$_DEL_OLD_BACKUPS" >> /root/.${_USER}.octopus.cnf echo "_DEL_OLD_TMP=$_DEL_OLD_TMP" >> /root/.${_USER}.octopus.cnf echo "_LOCAL_NETWORK_IP=$_LOCAL_NETWORK_IP" >> /root/.${_USER}.octopus.cnf echo "_PHP_FPM_VERSION=$_PHP_FPM_VERSION" >> /root/.${_USER}.octopus.cnf echo "_PHP_CLI_VERSION=$_PHP_CLI_VERSION" >> /root/.${_USER}.octopus.cnf echo "_PHP_FPM_WORKERS=$_PHP_FPM_WORKERS" >> /root/.${_USER}.octopus.cnf echo "_PHP_FPM_TIMEOUT=$_PHP_FPM_TIMEOUT" >> /root/.${_USER}.octopus.cnf echo "_PHP_FPM_DENY=\"$_PHP_FPM_DENY\"" >> /root/.${_USER}.octopus.cnf echo "_USE_STOCK=$_USE_STOCK" >> /root/.${_USER}.octopus.cnf echo "_STRONG_PASSWORDS=$_STRONG_PASSWORDS" >> /root/.${_USER}.octopus.cnf echo "_SQL_CONVERT=$_SQL_CONVERT" >> /root/.${_USER}.octopus.cnf echo "_RESERVED_RAM=$_RESERVED_RAM" >> /root/.${_USER}.octopus.cnf echo "###" >> /root/.${_USER}.octopus.cnf echo "### NOTE: the group of settings displayed bellow will be *overridden*" >> /root/.${_USER}.octopus.cnf echo "### by config files stored in the /data/disk/$_USER/log/ directory," >> /root/.${_USER}.octopus.cnf echo "### but only on upgrade." >> /root/.${_USER}.octopus.cnf echo "###" >> /root/.${_USER}.octopus.cnf echo "_DOMAIN=\"$_DOMAIN\"" >> /root/.${_USER}.octopus.cnf echo "_CLIENT_EMAIL=\"$_CLIENT_EMAIL\"" >> /root/.${_USER}.octopus.cnf echo "_CLIENT_OPTION=\"$_CLIENT_OPTION\"" >> /root/.${_USER}.octopus.cnf echo "_CLIENT_SUBSCR=\"$_CLIENT_SUBSCR\"" >> /root/.${_USER}.octopus.cnf echo "_CLIENT_CORES=\"$_CLIENT_CORES\"" >> /root/.${_USER}.octopus.cnf echo "###" >> /root/.${_USER}.octopus.cnf echo "### Configuration created on $_NOW with" >> /root/.${_USER}.octopus.cnf echo "### Octopus version $_INSTALLER_VERSION" >> /root/.${_USER}.octopus.cnf echo "###" >> /root/.${_USER}.octopus.cnf else msg "INFO: Reading your /root/.${_USER}.octopus.cnf config file" sleep 1 _PHP_FPM_WORKERS_TEST=$(grep _PHP_FPM_WORKERS /root/.${_USER}.octopus.cnf) if [[ "$_PHP_FPM_WORKERS_TEST" =~ "_PHP_FPM_WORKERS" ]] ; then _DO_NOTHING=YES else echo "_PHP_FPM_WORKERS=$_PHP_FPM_WORKERS" >> /root/.${_USER}.octopus.cnf fi _PHP_FPM_TIMEOUT_TEST=$(grep _PHP_FPM_TIMEOUT /root/.${_USER}.octopus.cnf) if [[ "$_PHP_FPM_TIMEOUT_TEST" =~ "_PHP_FPM_TIMEOUT" ]] ; then _DO_NOTHING=YES else echo "_PHP_FPM_TIMEOUT=$_PHP_FPM_TIMEOUT" >> /root/.${_USER}.octopus.cnf fi _PHP_FPM_DENY_TEST=$(grep _PHP_FPM_DENY /root/.${_USER}.octopus.cnf) if [[ "$_PHP_FPM_DENY_TEST" =~ "_PHP_FPM_DENY" ]] ; then _DO_NOTHING=YES else echo "_PHP_FPM_DENY=\"$_PHP_FPM_DENY\"" >> /root/.${_USER}.octopus.cnf fi _RESERVED_RAM_TEST=$(grep _RESERVED_RAM /root/.${_USER}.octopus.cnf) if [[ "$_RESERVED_RAM_TEST" =~ "_RESERVED_RAM" ]] ; then _DO_NOTHING=YES else echo "_RESERVED_RAM=$_RESERVED_RAM" >> /root/.${_USER}.octopus.cnf fi _PHP_FPM_VERSION_TEST=$(grep _PHP_FPM_VERSION /root/.${_USER}.octopus.cnf) if [[ "$_PHP_FPM_VERSION_TEST" =~ "_PHP_FPM_VERSION" ]] ; then _DO_NOTHING=YES else echo "_PHP_FPM_VERSION=$_PHP_FPM_VERSION" >> /root/.${_USER}.octopus.cnf fi _PHP_CLI_VERSION_TEST=$(grep _PHP_CLI_VERSION /root/.${_USER}.octopus.cnf) if [[ "$_PHP_CLI_VERSION_TEST" =~ "_PHP_CLI_VERSION" ]] ; then _DO_NOTHING=YES else echo "_PHP_CLI_VERSION=$_PHP_CLI_VERSION" >> /root/.${_USER}.octopus.cnf fi _CHECK_HOST=`uname -n` if [[ "$_CHECK_HOST" =~ ".host8." ]] || [ "$_VMFAMILY" = "VS" ] ; then _LD_DOM=YES else _LD_DOM=NO fi if [ -e "/data/disk/$_USER/static/control/fpm.info" ] ; then _PHP_FPM_VERSION=`cat /data/disk/$_USER/static/control/fpm.info` _PHP_FPM_VERSION=`echo -n $_PHP_FPM_VERSION | tr -d "\n"` if [ "$_PHP_FPM_VERSION" = "5.5" ] || [ "$_PHP_FPM_VERSION" = "5.4" ] || [ "$_PHP_FPM_VERSION" = "5.3" ] || [ "$_PHP_FPM_VERSION" = "5.2" ]; then sed -i "s/.*_PHP_FPM_VERSION.*/_PHP_FPM_VERSION=$_PHP_FPM_VERSION/g" /root/.${_USER}.octopus.cnf &> /dev/null fi else if [ -e "/data/disk/$_USER/log/fpm.txt" ] && [ "$_LD_DOM" = "YES" ] ; then _PHP_FPM_VERSION=`cat /data/disk/$_USER/log/fpm.txt` _PHP_FPM_VERSION=`echo -n $_PHP_FPM_VERSION | tr -d "\n"` if [ "$_PHP_FPM_VERSION" = "5.5" ] || [ "$_PHP_FPM_VERSION" = "5.4" ] || [ "$_PHP_FPM_VERSION" = "5.3" ] || [ "$_PHP_FPM_VERSION" = "5.2" ]; then sed -i "s/.*_PHP_FPM_VERSION.*/_PHP_FPM_VERSION=$_PHP_FPM_VERSION/g" /root/.${_USER}.octopus.cnf &> /dev/null fi fi fi if [ -e "/data/disk/$_USER/static/control/cli.info" ] ; then _PHP_CLI_VERSION=`cat /data/disk/$_USER/static/control/cli.info` _PHP_CLI_VERSION=`echo -n $_PHP_CLI_VERSION | tr -d "\n"` if [ "$_PHP_CLI_VERSION" = "5.5" ] || [ "$_PHP_CLI_VERSION" = "5.4" ] || [ "$_PHP_CLI_VERSION" = "5.3" ] || [ "$_PHP_CLI_VERSION" = "5.2" ]; then sed -i "s/.*_PHP_CLI_VERSION.*/_PHP_CLI_VERSION=$_PHP_CLI_VERSION/g" /root/.${_USER}.octopus.cnf &> /dev/null fi else if [ -e "/data/disk/$_USER/log/cli.txt" ] && [ "$_LD_DOM" = "YES" ] ; then _PHP_CLI_VERSION=`cat /data/disk/$_USER/log/cli.txt` _PHP_CLI_VERSION=`echo -n $_PHP_CLI_VERSION | tr -d "\n"` if [ "$_PHP_CLI_VERSION" = "5.5" ] || [ "$_PHP_CLI_VERSION" = "5.4" ] || [ "$_PHP_CLI_VERSION" = "5.3" ] || [ "$_PHP_CLI_VERSION" = "5.2" ]; then sed -i "s/.*_PHP_CLI_VERSION.*/_PHP_CLI_VERSION=$_PHP_CLI_VERSION/g" /root/.${_USER}.octopus.cnf &> /dev/null fi fi fi _ALLOW_UNSUPPORTED_TEST=$(grep _ALLOW_UNSUPPORTED /root/.${_USER}.octopus.cnf) if [[ "$_ALLOW_UNSUPPORTED_TEST" =~ "_ALLOW_UNSUPPORTED" ]] ; then _DO_NOTHING=YES else echo "_ALLOW_UNSUPPORTED=$_ALLOW_UNSUPPORTED" >> /root/.${_USER}.octopus.cnf fi _USE_STOCK_TEST=$(grep _USE_STOCK /root/.${_USER}.octopus.cnf) if [[ "$_USE_STOCK_TEST" =~ "_USE_STOCK" ]] ; then _DO_NOTHING=YES else echo "_USE_STOCK=$_USE_STOCK" >> /root/.${_USER}.octopus.cnf fi _DEL_OLD_EMPTY_PLATFORMS_TEST=$(grep _DEL_OLD_EMPTY_PLATFORMS /root/.${_USER}.octopus.cnf) if [[ "$_DEL_OLD_EMPTY_PLATFORMS_TEST" =~ "_DEL_OLD_EMPTY_PLATFORMS" ]] ; then _DO_NOTHING=YES else echo "_DEL_OLD_EMPTY_PLATFORMS=$_DEL_OLD_EMPTY_PLATFORMS" >> /root/.${_USER}.octopus.cnf fi _DEL_OLD_BACKUPS_TEST=$(grep _DEL_OLD_BACKUPS /root/.${_USER}.octopus.cnf) if [[ "$_DEL_OLD_BACKUPS_TEST" =~ "_DEL_OLD_BACKUPS" ]] ; then _DO_NOTHING=YES else echo "_DEL_OLD_BACKUPS=$_DEL_OLD_BACKUPS" >> /root/.${_USER}.octopus.cnf fi _DEL_OLD_TMP_TEST=$(grep _DEL_OLD_TMP /root/.${_USER}.octopus.cnf) if [[ "$_DEL_OLD_TMP_TEST" =~ "_DEL_OLD_TMP" ]] ; then _DO_NOTHING=YES else echo "_DEL_OLD_TMP=$_DEL_OLD_TMP" >> /root/.${_USER}.octopus.cnf fi if [ "$_LD_DOM" = "YES" ] ; then _STRONG_PASSWORDS=YES fi _STRONG_PASSWORDS_TEST=$(grep _STRONG_PASSWORDS /root/.${_USER}.octopus.cnf) if [[ "$_STRONG_PASSWORDS_TEST" =~ "_STRONG_PASSWORDS" ]] ; then _DO_NOTHING=YES else echo "_STRONG_PASSWORDS=$_STRONG_PASSWORDS" >> /root/.${_USER}.octopus.cnf fi _SQL_CONVERT_TEST=$(grep _SQL_CONVERT /root/.${_USER}.octopus.cnf) if [[ "$_SQL_CONVERT_TEST" =~ "_SQL_CONVERT" ]] ; then _DO_NOTHING=YES else echo "_SQL_CONVERT=$_SQL_CONVERT" >> /root/.${_USER}.octopus.cnf fi msg "NOTE! Please review all config options displayed below" sleep 3 echo " " while read line ; do echo "$line" done < /root/.${_USER}.octopus.cnf echo " " if [ -e "/root/.${_USER}.octopus.cnf" ] ; then source /root/.${_USER}.octopus.cnf fi if [[ "$_MY_EMAIL" =~ "omega8.cc" ]] ; then if [ -e "/root/.host8.cnf" ] || [[ "$_CHECK_HOST" =~ ".host8." ]] || [ "$_VMFAMILY" = "VS" ] ; then _DO_NOTHING=YES else msg "EXIT: You must enter **your** valid e-mail address in the _MY_EMAIL variable" msg "EXIT: stored in the /root/.${_USER}.octopus.cnf config file" exit 1 fi fi if [ "$_PHP_FPM_VERSION" = "5.5" ] || [ "$_PHP_CLI_VERSION" = "5.5" ] ; then if [ ! -x "/opt/php55/bin/php" ] && [ -x "/opt/php53/bin/php" ] ; then _PHP_FPM_VERSION=5.3 _PHP_CLI_VERSION=5.3 fi elif [ "$_PHP_FPM_VERSION" = "5.4" ] || [ "$_PHP_CLI_VERSION" = "5.4" ] ; then if [ ! -x "/opt/php54/bin/php" ] && [ -x "/opt/php53/bin/php" ] ; then _PHP_FPM_VERSION=5.3 _PHP_CLI_VERSION=5.3 fi elif [ "$_PHP_FPM_VERSION" = "5.2" ] || [ "$_PHP_CLI_VERSION" = "5.2" ] ; then if [ ! -x "/opt/php52/bin/php" ] && [ -x "/opt/php53/bin/php" ] ; then _PHP_FPM_VERSION=5.3 _PHP_CLI_VERSION=5.3 fi fi if [ "$_PHP_FPM_VERSION" = "5.3" ] || [ "$_PHP_CLI_VERSION" = "5.3" ] ; then if [ ! -x "/opt/php53/bin/php" ] ; then msg "EXIT: You must specify already installed PHP version" msg "EXIT: in both _PHP_FPM_VERSION and _PHP_CLI_VERSION" exit 1 fi fi if [ "$_DRUSH_VERSION" = "mini-4-14-03-2014" ] ; then _DRUSH_CC_REQ=NO else _DRUSH_CC_REQ=YES fi if [ "$_STATUS" = "INIT" ] ; then if prompt_yes_no "Do you want to proceed with the install?" ; then true else echo "Installation aborted by you" exit 1 fi else if prompt_yes_no "Do you want to proceed with the upgrade?" ; then true else echo "Upgrade aborted by you" exit 1 fi fi fi } # # Fix advanced cron IP for cURL requests. fix_advanced_cron_curl () { if [ -e "/data/disk/$_USER/.drush/hostmaster.alias.drushrc.php" ] ; then _THIS_HM_ROOT=`cat /data/disk/$_USER/.drush/hostmaster.alias.drushrc.php | grep "root'" | cut -d: -f2 | awk '{ print $3}' | sed "s/[\,']//g"` if [ -e "$_THIS_HM_ROOT/profiles/hostmaster/modules/hosting_advanced_cron" ] ; then sed -i "s/127.0.0.1/$_CRON_IP/g" $_THIS_HM_ROOT/profiles/hostmaster/modules/hosting_advanced_cron/hosting_advanced_cron.module &> /dev/null fi fi } # # Fix multi-IP cron access. fix_multi_ip_cron_access () { rm -f /root/.local.IP.list.allow for _IP in `cat /root/.local.IP.list | cut -d '#' -f1 | sort | uniq | tr -d "\s"`;do echo " allow $_IP;" >> /root/.local.IP.list.allow;done echo " allow 127.0.0.1;" >> /root/.local.IP.list.allow echo " deny all;" >> /root/.local.IP.list.allow sed -i "s/allow .*;//g; s/ *$//g; /^$/d" $_THIS_NGX_PATH/*.conf &> /dev/null sed -i '/deny all;/ {r /root/.local.IP.list.allow d;};' $_THIS_NGX_PATH/*.conf &> /dev/null } # # Sub Force advanced Nginx configuration. sub_force_advanced_nginx_config () { if [ -d "$_THIS_NGX_PATH" ] ; then _PHP_SV=${_PHP_FPM_VERSION//[^0-9]/} if [ -z "$_PHP_SV" ] ; then _PHP_SV=53 fi _PHP_CN="www${_PHP_SV}" if [ "$_USE_STOCK" = "NO" ] ; then sed -i "s/EDIT_USER/$_USER/g" $_THIS_NGX_PATH/nginx_octopus_include.conf &> /dev/null sed -i "s/EDIT_USER/$_USER/g" $_THIS_NGX_PATH/nginx_modern_include.conf &> /dev/null sed -i "s/EDIT_USER/$_USER/g" $_THIS_NGX_PATH/nginx_legacy_include.conf &> /dev/null fi if [ "$_PHP_FPM_VERSION" != "5.2" ] && [ -e "/opt/php${_PHP_SV}/etc/php${_PHP_SV}-fpm.conf" ] ; then if [ "$_USE_STOCK" = "NO" ] ; then sed -i "s/127.0.0.1:.*;/unix:\/var\/run\/${_USER}.fpm.socket;/g" $_THIS_NGX_PATH/nginx_modern_include.conf &> /dev/null sed -i "s/127.0.0.1:.*;/unix:\/var\/run\/${_USER}.fpm.socket;/g" $_THIS_NGX_PATH/nginx_octopus_include.conf &> /dev/null if [ "$_PHP_CN" = "www53" ] ; then if [ ! -z "$_PHP_FPM_DENY" ] ; then sed -i "s/unix:cron:fastcgi.socket;/127.0.0.1:9090;/g" $_THIS_NGX_PATH/nginx_modern_include.conf &> /dev/null sed -i "s/unix:cron:fastcgi.socket;/127.0.0.1:9090;/g" $_THIS_NGX_PATH/nginx_octopus_include.conf &> /dev/null else sed -i "s/unix:cron:fastcgi.socket;/unix:\/var\/run\/${_USER}.fpm.socket;/g" $_THIS_NGX_PATH/nginx_modern_include.conf &> /dev/null sed -i "s/unix:cron:fastcgi.socket;/unix:\/var\/run\/${_USER}.fpm.socket;/g" $_THIS_NGX_PATH/nginx_octopus_include.conf &> /dev/null fi else if [ ! -z "$_PHP_FPM_DENY" ] && [ ! -z "$_PHP_CN" ] ; then sed -i "s/unix:cron:fastcgi.socket;/unix:\/var\/run\/${_PHP_CN}.fpm.socket;/g" $_THIS_NGX_PATH/nginx_modern_include.conf &> /dev/null sed -i "s/unix:cron:fastcgi.socket;/unix:\/var\/run\/${_PHP_CN}.fpm.socket;/g" $_THIS_NGX_PATH/nginx_octopus_include.conf &> /dev/null else sed -i "s/unix:cron:fastcgi.socket;/unix:\/var\/run\/${_USER}.fpm.socket;/g" $_THIS_NGX_PATH/nginx_modern_include.conf &> /dev/null sed -i "s/unix:cron:fastcgi.socket;/unix:\/var\/run\/${_USER}.fpm.socket;/g" $_THIS_NGX_PATH/nginx_octopus_include.conf &> /dev/null fi fi else sed -i "s/127.0.0.1:.*;/unix:\/var\/run\/$_USER.fpm.socket;/g" $_THIS_NGX_PATH/nginx_vhost_common.conf &> /dev/null if [ "$_PHP_CN" = "www53" ] ; then sed -i "s/unix:cron:fastcgi.socket;/127.0.0.1:9090;/g" $_THIS_NGX_PATH/nginx_vhost_common.conf &> /dev/null else sed -i "s/unix:cron:fastcgi.socket;/unix:\/var\/run\/${_PHP_CN}.fpm.socket;/g" $_THIS_NGX_PATH/nginx_vhost_common.conf &> /dev/null fi fi else if [ "$_USE_STOCK" = "NO" ] ; then sed -i "s/127.0.0.1:.*;/127.0.0.1:9000;/g" $_THIS_NGX_PATH/nginx_octopus_include.conf &> /dev/null sed -i "s/unix:cron:fastcgi.socket;/127.0.0.1:9000;/g" $_THIS_NGX_PATH/nginx_octopus_include.conf &> /dev/null else sed -i "s/127.0.0.1:.*;/127.0.0.1:9000;/g" $_THIS_NGX_PATH/nginx_vhost_common.conf &> /dev/null sed -i "s/unix:cron:fastcgi.socket;/127.0.0.1:9000;/g" $_THIS_NGX_PATH/nginx_vhost_common.conf &> /dev/null fi fi _PHP_CLI_LEGACY_IF_USED_A=`grep "5\.2" /data/disk/$_USER/log/cli.txt 2>&1` _PHP_CLI_LEGACY_IF_USED_B=`grep "5\.2" /data/disk/$_USER/static/control/cli.info 2>&1` _PHP_CLI_LEGACY_IF_USED_C=`grep "CLI.*5\.2" /root/.$_USER.octopus.cnf 2>&1` if [[ "$_PHP_CLI_LEGACY_IF_USED_A" =~ "5.2" ]] || [[ "$_PHP_CLI_LEGACY_IF_USED_B" =~ "5.2" ]] || [[ "$_PHP_CLI_LEGACY_IF_USED_C" =~ "5.2" ]] ; then _PHP_CLI_LEGACY_FREE=NO else _PHP_CLI_LEGACY_FREE=YES fi _PHP_FPM_LEGACY_IF_USED_A=`grep "5\.2" /data/disk/$_USER/log/fpm.txt 2>&1` _PHP_FPM_LEGACY_IF_USED_B=`grep "5\.2" /data/disk/$_USER/static/control/fpm.info 2>&1` _PHP_FPM_LEGACY_IF_USED_C=`grep "FPM.*5\.2" /root/.$_USER.octopus.cnf 2>&1` if [[ "$_PHP_FPM_LEGACY_IF_USED_A" =~ "5.2" ]] || [[ "$_PHP_FPM_LEGACY_IF_USED_B" =~ "5.2" ]] || [[ "$_PHP_FPM_LEGACY_IF_USED_C" =~ "5.2" ]] ; then _PHP_FPM_LEGACY_FREE=NO else _PHP_FPM_LEGACY_FREE=YES fi if [ "$_PHP_CLI_LEGACY_FREE" = "YES" ] && [ "$_PHP_FPM_LEGACY_FREE" = "YES" ] ; then _PHP_LEGACY_FREE=YES else _PHP_LEGACY_FREE=NO fi if [ "$_PHP_LEGACY_FREE" = "YES" ] || [ "$_PHP_FPM_VERSION" != "5.2" ] ; then if [ "$_PHP_CN" = "www53" ] ; then sed -i "s/127.0.0.1:.*;/127.0.0.1:9090;/g" $_THIS_NGX_PATH/nginx_legacy_include.conf &> /dev/null else sed -i "s/127.0.0.1:.*;/unix:\/var\/run\/$_USER.fpm.socket;/g" $_THIS_NGX_PATH/nginx_legacy_include.conf &> /dev/null fi fi _CRON_IP=${_THISHTIP//[^0-9.]/} if [ ! -e "/root/.local.IP.list" ] ; then rm -f /root/.tmp.IP.list* rm -f /root/.local.IP.list* for _IP in `hostname -I`;do echo $_IP >> /root/.tmp.IP.list;done for _IP in `cat /root/.tmp.IP.list | sort | uniq`;do echo "$_IP # local IP address" >> /root/.local.IP.list;done rm -f /root/.tmp.IP.list* fi _IP_IF_PRESENT=$(grep "$_CRON_IP" /root/.local.IP.list) if [[ "$_IP_IF_PRESENT" =~ "$_CRON_IP" ]] ; then _IP_PRESENT=YES else _IP_PRESENT=NO fi if [ ! -z "$_CRON_IP" ] && [ "$_IP_PRESENT" = "YES" ] && [ -e "/root/.local.IP.list" ] ; then fix_multi_ip_cron_access fix_advanced_cron_curl fi fi } # # Force advanced Nginx configuration. force_advanced_nginx_config () { _THIS_NGX_PATH=/data/disk/$_USER/.drush/sys/provision/http/Provision/Service/http sub_force_advanced_nginx_config _THIS_NGX_PATH=/data/disk/$_USER/config/includes sub_force_advanced_nginx_config if [ -e "/data/disk/$_USER/config/includes" ] && [ "$_USE_STOCK" = "NO" ] ; then if [ ! -L "/data/disk/$_USER/config/includes/nginx_advanced_include.conf" ] ; then ln -sf /data/disk/$_USER/config/includes/nginx_octopus_include.conf /data/disk/$_USER/config/includes/nginx_advanced_include.conf fi if [ ! -L "/data/disk/$_USER/config/includes/nginx_simple_include.conf" ] ; then ln -sf /data/disk/$_USER/config/includes/nginx_legacy_include.conf /data/disk/$_USER/config/includes/nginx_simple_include.conf fi fi } # # ###---### action # action () { _REL_VERSION=`lsb_release -sc` _AWS_TEST_A=$(grep cloudimg /etc/fstab) _AWS_TEST_B=$(grep cloudconfig /etc/fstab) if [ "$_REL_VERSION" = "trusty" ] || [ "$_REL_VERSION" = "precise" ] || [ "$_REL_VERSION" = "oneiric" ] ; then _THIS_DB_HOST=localhost fi if [[ "$_AWS_TEST_A" =~ "cloudimg" ]] || [[ "$_AWS_TEST_B" =~ "cloudconfig" ]] ; then _VMFAMILY="AWS" _THIS_DB_HOST=localhost _LOC_DOM="$_DOMAIN" find_correct_ip _MY_OWNIP="$_LOC_IP" fi if [ -d "/data/all/000" ] ; then if [ ! -e "/data/all/000/core-v-$_SMALLCORE6.txt" ] || [ ! -e "/data/all/000/core-v-$_SMALLCORE7.txt" ] ; then _USE_CURRENT=NO _HOT_SAUCE=YES _HM_ONLY=NO fi fi for Files in `find /opt/tmp/$_BOA_REPO_NAME/aegir/scripts -type f` do sed -i "s/EDIT_AEGIR_VERSION/$_AEGIR_VERSION/g" $Files &> /dev/null sed -i "s/EDIT_AGOV/$_AGOV/g" $Files &> /dev/null sed -i "s/EDIT_ALL_DISTRO/$_ALL_DISTRO/g" $Files &> /dev/null sed -i "s/EDIT_ALLOW_UNSUPPORTED/$_ALLOW_UNSUPPORTED/g" $Files &> /dev/null sed -i "s/EDIT_AUTOPILOT/$_AUTOPILOT/g" $Files &> /dev/null sed -i "s/EDIT_BOA_REPO_GIT_URL/$_BOA_REPO_GIT_URLX/g" $Files &> /dev/null sed -i "s/EDIT_BOA_REPO_NAME/$_BOA_REPO_NAME/g" $Files &> /dev/null sed -i "s/EDIT_CIVICRM_M6/$_CIVICRM_M6/g" $Files &> /dev/null sed -i "s/EDIT_CIVICRM_M7/$_CIVICRM_M7/g" $Files &> /dev/null sed -i "s/EDIT_CIVICRM_PN/$_CIVICRM_PN/g" $Files &> /dev/null sed -i "s/EDIT_CLIENT_CORES/$_CLIENT_CORES/g" $Files &> /dev/null sed -i "s/EDIT_CLIENT_EMAIL/$_CLIENT_EMAIL/g" $Files &> /dev/null sed -i "s/EDIT_CLIENT_OPTION/$_CLIENT_OPTION/g" $Files &> /dev/null sed -i "s/EDIT_COD/$_COD/g" $Files &> /dev/null sed -i "s/EDIT_COMMERCE1/$_COMMERCE1/g" $Files &> /dev/null sed -i "s/EDIT_COMMERCE2/$_COMMERCE2/g" $Files &> /dev/null sed -i "s/EDIT_COMMONS2/$_COMMONS2/g" $Files &> /dev/null sed -i "s/EDIT_COMMONS3/$_COMMONS3/g" $Files &> /dev/null sed -i "s/EDIT_DEBUG_MODE/$_DEBUG_MODE/g" $Files &> /dev/null sed -i "s/EDIT_DISTRO/$_DISTRO/g" $Files &> /dev/null sed -i "s/EDIT_DOMAIN/$_DOMAIN/g" $Files &> /dev/null sed -i "s/EDIT_DRUPAL_EDGE_8/$_DRUPAL_EDGE_8/g" $Files &> /dev/null sed -i "s/EDIT_DRUPAL7/$_DRUPAL7/g" $Files &> /dev/null sed -i "s/EDIT_DRUPAL8/$_DRUPAL8/g" $Files &> /dev/null sed -i "s/EDIT_DRUSH_CC_REQ/$_DRUSH_CC_REQ/g" $Files &> /dev/null sed -i "s/EDIT_DRUSH_VERSION/$_DRUSH_VERSION/g" $Files &> /dev/null sed -i "s/EDIT_ERPAL/$_ERPAL/g" $Files &> /dev/null sed -i "s/EDIT_GUARDR/$_GUARDR/g" $Files &> /dev/null sed -i "s/EDIT_HM_DISTRO/$_HM_DISTRO/g" $Files &> /dev/null sed -i "s/EDIT_HM_ONLY/$_HM_ONLY/g" $Files &> /dev/null sed -i "s/EDIT_HOT_SAUCE/$_HOT_SAUCE/g" $Files &> /dev/null sed -i "s/EDIT_HTTP_WILDCARD/$_HTTP_WILDCARD/g" $Files &> /dev/null sed -i "s/EDIT_INSTALLER_VERSION/$_INSTALLER_VERSION/g" $Files &> /dev/null sed -i "s/EDIT_LAST_ALL/$_LAST_ALL/g" $Files &> /dev/null sed -i "s/EDIT_LAST_HMR/$_LAST_HMR/g" $Files &> /dev/null sed -i "s/EDIT_LASTNUM/$_LASTNUM/g" $Files &> /dev/null sed -i "s/EDIT_MANAGINGNEWS/$_MANAGINGNEWS/g" $Files &> /dev/null sed -i "s/EDIT_MY_EMAIL/$_MY_EMAIL/g" $Files &> /dev/null sed -i "s/EDIT_NODESTREAM7/$_NODESTREAM7/g" $Files &> /dev/null sed -i "s/EDIT_NOW/$_NOW/g" $Files &> /dev/null sed -i "s/EDIT_O_CONTRIB_UP/$_O_CONTRIB_UP/g" $Files &> /dev/null sed -i "s/EDIT_OPEN_DEALS/$_OPEN_DEALS/g" $Files &> /dev/null sed -i "s/EDIT_OPENACADEMY/$_OPENACADEMY/g" $Files &> /dev/null sed -i "s/EDIT_OPENATRIUM6/$_OPENATRIUM6/g" $Files &> /dev/null sed -i "s/EDIT_OPENATRIUM7/$_OPENATRIUM7/g" $Files &> /dev/null sed -i "s/EDIT_OPENBLOG/$_OPENBLOG/g" $Files &> /dev/null sed -i "s/EDIT_OPENCHURCH/$_OPENCHURCH/g" $Files &> /dev/null sed -i "s/EDIT_OPENDEALS/$_OPENDEALS/g" $Files &> /dev/null sed -i "s/EDIT_OPENOUTREACH/$_OPENOUTREACH/g" $Files &> /dev/null sed -i "s/EDIT_OPENPUBLISH/$_OPENPUBLISH/g" $Files &> /dev/null sed -i "s/EDIT_OPENSCHOLAR/$_OPENSCHOLAR/g" $Files &> /dev/null sed -i "s/EDIT_PANOPOLY/$_PANOPOLY/g" $Files &> /dev/null sed -i "s/EDIT_PHP_CLI_VERSION/$_PHP_CLI_VERSION/g" $Files &> /dev/null sed -i "s/EDIT_PHP_FPM_VERSION/$_PHP_FPM_VERSION/g" $Files &> /dev/null sed -i "s/EDIT_PLATFORMS_LIST/$_PLATFORMS_LIST/g" $Files &> /dev/null sed -i "s/EDIT_PLATFORMS_ONLY/$_PLATFORMS_ONLY/g" $Files &> /dev/null sed -i "s/EDIT_PROSEPOINT/$_PROSEPOINT/g" $Files &> /dev/null sed -i "s/EDIT_PURGE_FOR_SEVEN/$_PURGE_FOR_SEVEN/g" $Files &> /dev/null sed -i "s/EDIT_PURGE_MODE/$_PURGE_MODE/g" $Files &> /dev/null sed -i "s/EDIT_RECRUITER/$_RECRUITER/g" $Files &> /dev/null sed -i "s/EDIT_RESTAURANT/$_RESTAURANT/g" $Files &> /dev/null sed -i "s/EDIT_SMALLCORE6/$_SMALLCORE6/g" $Files &> /dev/null sed -i "s/EDIT_SMALLCORE7/$_SMALLCORE7/g" $Files &> /dev/null sed -i "s/EDIT_SMALLCORE8/$_SMALLCORE8/g" $Files &> /dev/null sed -i "s/EDIT_SPARK/$_SPARK/g" $Files &> /dev/null sed -i "s/EDIT_SPINNER/$_SPINNER/g" $Files &> /dev/null sed -i "s/EDIT_STRONG_PASSWORDS/$_STRONG_PASSWORDS/g" $Files &> /dev/null sed -i "s/EDIT_T_BUILD/$_T_BUILD/g" $Files &> /dev/null sed -i "s/EDIT_THIS_DB_HOST/$_THIS_DB_HOST/g" $Files &> /dev/null sed -i "s/EDIT_THISHTIP/$_THISHTIP/g" $Files &> /dev/null sed -i "s/EDIT_TOTEM/$_TOTEM/g" $Files &> /dev/null sed -i "s/EDIT_UBERCART6/$_UBERCART6/g" $Files &> /dev/null sed -i "s/EDIT_UBERCART7/$_UBERCART7/g" $Files &> /dev/null sed -i "s/EDIT_USE_CURRENT/$_USE_CURRENT/g" $Files &> /dev/null sed -i "s/EDIT_USE_STOCK/$_USE_STOCK/g" $Files &> /dev/null sed -i "s/EDIT_USER/$_USER/g" $Files &> /dev/null sed -i "s/EDIT_USRG/$_USRG/g" $Files &> /dev/null sed -i "s/EDIT_WEBG/$_WEBG/g" $Files &> /dev/null done _THISHOST=`cat /etc/hostname` _THISHOST=`echo -n $_THISHOST | tr -d "\n"` if [ -e "/usr/bin/sipcalc" ] ; then if [ -z "$_THISHTIP" ] ; then _LOC_DOM="$_THISHOST" find_correct_ip _THISHTIP="$_LOC_IP" fi _IP_TEST=`sipcalc $_THISHTIP 2>&1` if [[ "$_IP_TEST" =~ "ERR" ]] ; then _IP_TEST_RESULT=FAIL _LOCAL_THISHTIP=all else _IP_TEST_RESULT=OK _LOCAL_THISHTIP="$_THISHTIP" fi else _LOCAL_THISHTIP="$_THISHTIP" fi if [ -z "$_LOCAL_THISHTIP" ] ; then _LOC_DOM="$_THISHOST" find_correct_ip _LOCAL_THISHTIP="$_LOC_IP" fi if [ -z "$_LOCAL_THISHTIP" ] ; then _LOCAL_THISHTIP=all fi cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/scripts/run-xdrago /var/xdrago/run-$_USER &> /dev/null chmod 700 /var/xdrago/run-$_USER &> /dev/null chmod 700 /opt/tmp/$_BOA_REPO_NAME/aegir/scripts/* &> /dev/null bash /opt/tmp/$_BOA_REPO_NAME/aegir/scripts/AegirSetupA.sh.txt if [ -e "/opt/tmp/status-AegirSetupA-FAIL" ] ; then msg "FATAL ERROR: AegirSetupA installer failed" msg "FATAL ERROR: Aborting Octopus installer NOW!" touch /opt/tmp/status-Octopus-FAIL exit 1 fi if [ ! -e "/data/disk/$_USER/log/email.txt" ] ; then echo $_CLIENT_EMAIL > /data/disk/$_USER/log/email.txt fi if [ ! -e "/data/disk/$_USER/log/option.txt" ] ; then echo $_CLIENT_OPTION > /data/disk/$_USER/log/option.txt fi if [ ! -e "/data/disk/$_USER/log/cores.txt" ] ; then echo $_CLIENT_CORES > /data/disk/$_USER/log/cores.txt fi if [ ! -e "/data/disk/$_USER/log/subscr.txt" ] ; then echo $_CLIENT_SUBSCR > /data/disk/$_USER/log/subscr.txt fi if [ ! -e "/data/disk/$_USER/log/fpm.txt" ] ; then echo $_PHP_FPM_VERSION > /data/disk/$_USER/log/fpm.txt fi if [ ! -e "/data/disk/$_USER/log/cli.txt" ] ; then echo $_PHP_CLI_VERSION > /data/disk/$_USER/log/cli.txt fi if [ ! -e "/data/disk/${_USER}/static/control/.ctrl.eq.txt" ] || [ ! -e "/data/disk/${_USER}/static/control/README.txt" ] ; then mkdir -p /data/disk/${_USER}/static/control chmod 755 /data/disk/${_USER}/static/control if [ -e "/var/xdrago/conf/control-readme.txt" ] ; then cp -af /var/xdrago/conf/control-readme.txt /data/disk/${_USER}/static/control/README.txt &> /dev/null chmod 0644 /data/disk/${_USER}/static/control/README.txt fi chown -R ${_USER}.ftp:$_USRG /data/disk/${_USER}/static/control &> /dev/null echo OK > /data/disk/${_USER}/static/control/.ctrl.eq.txt fi if [ -d "/data/all/000" ] ; then if [ ! -e "/data/all/000/core-v-$_SMALLCORE6.txt" ] || [ ! -e "/data/all/000/core-v-$_SMALLCORE7.txt" ] ; then echo "$_SMALLCORE6" > /data/all/000/core-v-$_SMALLCORE6.txt echo "$_SMALLCORE7" > /data/all/000/core-v-$_SMALLCORE7.txt fi fi if [ -e "/data/disk/$_USER/log/email.txt" ] ; then tune_fpm_config force_advanced_nginx_config mrun "service nginx reload" &> /dev/null fi } ###--------------------### wait_for_connection () { echo " " msg "I can not connect to github.com on port 9418 at the moment" msg "I will try again in 60 seconds, please wait..." msg "Waiting for attempt $1..." sleep 60 } check_connection () { if ! netcat -w 8 -z github.com 9418 ; then wait_for_connection "2/4" if ! netcat -w 8 -z github.com 9418 ; then wait_for_connection "3/4" if ! netcat -w 8 -z github.com 9418 ; then wait_for_connection "4/4" if ! netcat -w 8 -z github.com 9418 ; then echo " " msg "Sorry, I gave up." msg "EXIT on error due to GitHub git server at 9418 downtime" msg "Please try to run this script again in a few minutes" msg "You may want to check https://status.github.com/messages" msg "Also, make sure that the git port 9418 is open" msg "Bye" exit 1 fi fi fi fi } if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_USE_STOCK" = "NO" ] ; then rm -f -r /opt/tmp/test-* check_connection _GITHUB_TEST=`git clone git://github.com/omega8cc/provision.git /opt/tmp/test-provision 2>&1` if [[ "$_GITHUB_TEST" =~ "fatal" ]] ; then echo " " msg "EXIT on error (provision) due to GitHub downtime" msg "Please try to run this script again in a few minutes" msg "You may want to check https://status.github.com/messages" msg "Bye" rm -f -r /opt/tmp/test-* exit 1 fi _GITHUB_TEST=`git clone git://github.com/omega8cc/hostmaster.git /opt/tmp/test-hostmaster 2>&1` if [[ "$_GITHUB_TEST" =~ "fatal" ]] ; then echo " " msg "EXIT on error (hostmaster) due to GitHub downtime" msg "Please try to run this script again in a few minutes" msg "You may want to check https://status.github.com/messages" msg "Bye" rm -f -r /opt/tmp/test-* exit 1 fi rm -f -r /opt/tmp/test-* fi if [[ "$_INSTALLER_VERSION" =~ "-dev" ]] && [ "$_USE_STOCK" = "NO" ] ; then rm -f -r /opt/tmp/test-* _GITHUB_TEST=`git clone git://github.com/omega8cc/boa.git /opt/tmp/test-boa 2>&1` if [[ "$_GITHUB_TEST" =~ "fatal" ]] ; then echo " " msg "EXIT on error (boa) due to GitHub downtime" msg "Please try to run this script again in a few minutes" msg "You may want to check https://status.github.com/messages" msg "Bye" rm -f -r /opt/tmp/test-* exit 1 fi rm -f -r /opt/tmp/test-* fi ###--------------------### if [ ! -e "/var/run/mysqld/mysqld.pid" ] || [ ! -e "/var/run/mysqld/mysqld.sock" ] ; then _DB_SERVER_TEST=`mysql -V 2>&1` if [[ "$_DB_SERVER_TEST" =~ "MariaDB" ]] ; then _DB_SERVER=MariaDB else _DB_SERVER=Percona fi msg "ALRT: $_DB_SERVER server not running properly!" msg "EXIT: We can't proceed and will exit now" msg "HINT: Please (re)start $_DB_SERVER server and then run installer again" msg "Bye" exit 1 fi ###--------------------### _LASTNUM=001 _LAST_HMR=001 _LAST_ALL=001 _DISTRO=001 _HM_DISTRO=001 _ALL_DISTRO=001 _STATUS=INIT ###---### START # # Make sure it is running as root if [ `whoami` = "root" ] ; then chmod a+w /dev/null if [ ! -e "/dev/fd" ] ; then if [ -e "/proc/self/fd" ] ; then rm -rf /dev/fd ln -s /proc/self/fd /dev/fd fi fi else msg "ERROR: This script should be ran as a root user - please `sudo -i` first" msg "Bye" exit 1 fi # # Restart pdnsd server touch /var/run/boa_run.pid if [ -d "/var/cache/pdnsd" ] ; then service pdnsd stop &> /dev/null sleep 1 rm -f /var/cache/pdnsd/pdnsd.cache sleep 1 service pdnsd start &> /dev/null fi # # Sanitize _USER and check the status _USER=${_USER//[^a-zA-Z0-9-.]/} _USER=`echo -n $_USER | tr A-Z a-z` _ROOT="/data/disk/$_USER" if [ -d "$_ROOT" ] ; then _STATUS=UPGRADE fi if [ "$_STATUS" = "INIT" ] ; then check_id fi echo " " msg "BOA Skynet welcomes you aboard!" echo " " sleep 3 # # Some auto-magic for localhost install _THIS_HOST=`uname -n` if [ $_THIS_HOST = "aegir.local" ] && [ ! -d "$_ROOT" ] ; then _PHP_FPM_VERSION=5.3 _PHP_CLI_VERSION=5.3 _AEGIR_VERSION=HEAD _DEBUG_MODE=NO _DNS_SETUP_TEST=NO _THIS_DB_HOST=localhost _DOMAIN="$_USER.sub.aegir.local" _LOCAL_NETWORK_IP="127.0.1.1" _MY_OWNIP="$_LOCAL_NETWORK_IP" msg "_LOCAL_NETWORK_IP is $_LOCAL_NETWORK_IP" fi # # Sanitize _DOMAIN _DOMAIN=${_DOMAIN//[^a-zA-Z0-9-.]/} _DOMAIN=`echo -n $_DOMAIN | tr A-Z a-z` # # Detect VM family _ETH_TEST=`ifconfig 2>&1` if [[ "$_ETH_TEST" =~ "venet0" ]] ; then _IFCONFIG="venet0" elif [ -e "/proc/bean_counters" ] ; then _IFCONFIG="venet0" else _IFCONFIG="eth0" fi _VM_TEST=`uname -a 2>&1` if [[ "$_VM_TEST" =~ beng ]] ; then _VMFAMILY="VS" else _VMFAMILY="XEN" fi # # if [[ "$_DOMAIN" =~ ".xhost8." ]] ; then _DO_NOTHING=YES else octopus_cnf fi # # if [ ! -z "$_LOCAL_NETWORK_IP" ] && [ $_THIS_HOST != "aegir.local" ] ; then _DNS_SETUP_TEST=NO _MY_OWNIP="$_LOCAL_NETWORK_IP" fi # # _BOA_REPO_NAME="boa" _BOA_REPO_GIT_URL="git://github.com/omega8cc" _BOA_REPO_GIT_URLX=${_BOA_REPO_GIT_URL//\//\\\/} if [ "$_AEGIR_VERSION" = "HEAD" ] && [ "$_USE_STOCK" = "NO" ] ; then check_git_repos_status fi # # if [ ! -f "/var/log/barracuda_log.txt" ] ; then msg "ERROR: This script should be used only when the same version of BARRACUDA was used before" msg "Your system has to be configured/upgraded by BARRACUDA version $_INSTALLER_VERSION first" msg "Bye" exit 1 else _VERSIONS_TEST=`cat /var/log/barracuda_log.txt` if [[ "$_VERSIONS_TEST" =~ "$_INSTALLER_VERSION" ]] ; then _VERSIONS_TEST_RESULT=OK else msg "ERROR: This script should be used only when the same version of BARRACUDA was used before" msg "Your system has to be configured/upgraded by BARRACUDA version $_INSTALLER_VERSION first" msg "Bye" exit 1 fi fi if [ -e "/var/log/barracuda_log.txt" ] ; then _LEGACY_TEST=`cat /var/log/barracuda_log.txt` if [[ "$_LEGACY_TEST" =~ "BOA-2.3." ]] && [[ "$_INSTALLER_VERSION" =~ "BOA-2.2." ]] ; then msg "ERROR: Your system has been already upgraded to BOA-2.3.x series" msg "ERROR: You can not downgrade back to legacy BOA-2.2.x series" msg "ERROR: Please use octopus up-stable to upgrade this instance" msg "Bye" exit 1 fi fi # # rm -f /var/run/aegir_upgrade.pid rm -f /opt/tmp/testecho* _SRCDIR=/opt/tmp/files mkdir -p $_SRCDIR chmod -R 777 /opt/tmp &> /dev/null cd /opt/tmp rm -f -r /opt/tmp/$_BOA_REPO_NAME if [ "$_AEGIR_VERSION" = "HEAD" ] ; then git clone $_BOA_REPO_GIT_URL/$_BOA_REPO_NAME.git &> /dev/null if [ "$_FORCE_GIT_MIRROR" = "gitorious" ] ; then cd /opt/tmp/$_BOA_REPO_NAME git checkout 2.0.4-dev &> /dev/null cd /opt/tmp fi else curl -L --max-redirs 10 -k -s --retry 10 --retry-delay 15 -A iCab "http://files.aegir.cc/versions/stable/tar/boa-$_INSTALLER_VERSION.tar.gz" | tar -xzf - _BOA_REPO_NAME="boa" fi if [ ! -e "/opt/tmp/$_BOA_REPO_NAME/aegir/helpers/apt.conf.noninteractive" ] ; then echo " " msg "EXIT on error due to missing helpers" msg "Please try to run this script again in a few minutes" msg "Also, make sure that the git port 9418 is open" msg "Bye" exit 1 fi # # Get spinner cd $_SRCDIR rm -f spinner* cp -af /opt/tmp/$_BOA_REPO_NAME/aegir/helpers/spinner ./ chmod +x spinner &> /dev/null # # Create tmp stuff _LOG=/var/backups/octopus-$_USER-$_NOW.log touch $_LOG chmod 646 $_LOG _SILENT=/opt/tmp/silent.log # # if [ -d "$_ROOT" ] ; then msg "UPGRADE in progress..." if [ -d "$_ROOT/distro" ] ; then if [ -e "$_ROOT/log/domain.txt" ] ; then _DOMAIN=`cat $_ROOT/log/domain.txt` _DOMAIN=`echo -n $_DOMAIN | tr -d "\n"` fi if [ -z "$_DOMAIN" ] ; then msg "ALERT! _DOMAIN is e-m-p-t-y, exit now" exit 1 fi if [ -z "$_USER" ] ; then msg "ALERT! _USER is e-m-p-t-y, exit now" exit 1 fi _CHECK_HOST=`uname -n` if [ -e "/root/.host8.cnf" ] || [[ "$_CHECK_HOST" =~ ".host8." ]] || [ "$_VMFAMILY" = "VS" ] ; then if [ -e "/data/disk/$_USER/log/amazing_upgrade.txt" ] && [ ! -e "/data/disk/$_USER/log/amazing_upgrade_complete.txt" ] ; then if [ -e "/data/disk/$_USER/log/original_option.txt" ] ; then cp -af /data/disk/$_USER/log/option.txt /data/disk/$_USER/log/prev_option.txt cp -af /data/disk/$_USER/log/original_option.txt /data/disk/$_USER/log/option.txt fi if [ -e "/data/disk/$_USER/log/original_cores.txt" ] ; then cp -af /data/disk/$_USER/log/cores.txt /data/disk/$_USER/log/prev_cores.txt cp -af /data/disk/$_USER/log/original_cores.txt /data/disk/$_USER/log/cores.txt fi echo completed > /data/disk/$_USER/log/amazing_upgrade_complete.txt fi fi if [ -e "/data/disk/$_USER/log/option.txt" ] ; then _CLIENT_OPTION=`cat /data/disk/$_USER/log/option.txt` _CLIENT_OPTION=`echo -n $_CLIENT_OPTION | tr -d "\n"` fi if [ -e "/data/disk/$_USER/log/cores.txt" ] ; then _CLIENT_CORES=`cat /data/disk/$_USER/log/cores.txt` _CLIENT_CORES=`echo -n $_CLIENT_CORES | tr -d "\n"` fi if [ -e "/data/disk/$_USER/log/subscr.txt" ] ; then _CLIENT_SUBSCR=`cat /data/disk/$_USER/log/subscr.txt` _CLIENT_SUBSCR=`echo -n $_CLIENT_SUBSCR | tr -d "\n"` fi if [ -e "/data/disk/$_USER/log/email.txt" ] ; then _CLIENT_EMAIL=`cat /data/disk/$_USER/log/email.txt` _CLIENT_EMAIL=`echo -n $_CLIENT_EMAIL | tr -d "\n"` if [[ "$_CLIENT_EMAIL" =~ "@" ]] ; then _DO_NOTHING=YES else msg "EXIT: You must enter **your** valid e-mail address in the _CLIENT_EMAIL variable" msg "EXIT: stored both in the /root/.${_USER}.octopus.cnf config file **and**" msg "EXIT: in the /data/disk/$_USER/log/email.txt file" msg "EXIT: Bye (1)" exit 1 fi _CLIENT_EMAIL=${_CLIENT_EMAIL//\\\@/\@} fi if [[ "$_CLIENT_EMAIL" =~ "omega8.cc" ]] ; then _CHECK_HOST=`uname -n` if [ -e "/root/.host8.cnf" ] || [[ "$_CHECK_HOST" =~ ".host8." ]] || [ "$_VMFAMILY" = "VS" ] ; then _DO_NOTHING=YES else msg "EXIT: You must enter **your** valid e-mail address in the _CLIENT_EMAIL variable" msg "EXIT: stored both in the /root/.${_USER}.octopus.cnf config file **and**" msg "EXIT: in the /data/disk/$_USER/log/email.txt file" msg "EXIT: Bye (2)" exit 1 fi fi # # Check for last distro nr if [ -d "$_ROOT/distro" ] ; then cd $_ROOT/distro list=([0-9]*) last=${list[@]: -1} _LASTNUM=$last nextnum=00$((10#${last%%[^0-9]*} + 1)) nextnum=${nextnum: -3} _DISTRO=${nextnum} fi # # Check for last hm nr if [ -d "$_ROOT/aegir/distro" ] ; then cd $_ROOT/aegir/distro listx=([0-9]*) lastx=${listx[@]: -1} _LAST_HMR=$lastx nextnumx=00$((10#${lastx%%[^0-9]*} + 1)) nextnumx=${nextnumx: -3} _HM_DISTRO=${nextnumx} fi # # Check for last all nr if [ -d "/data/all" ] ; then cd /data/all listl=([0-9]*) lastl=${listl[@]: -1} _LAST_ALL=$lastl nextnuml=00$((10#${lastl%%[^0-9]*} + 1)) nextnuml=${nextnuml: -3} _ALL_DISTRO=${nextnuml} fi # # elif [ ! -d "$_ROOT/distro" ] ; then if [ -e "$_ROOT/log/domain.txt" ] ; then _DOMAIN=`cat $_ROOT/log/domain.txt` _DOMAIN=`echo -n $_DOMAIN | tr -d "\n"` fi fi else msg "NEW Aegir Satellite Instance setup in progress..." # # Check for last all nr if [ -d "/data/all" ] ; then cd /data/all listl=([0-9]*) lastl=${listl[@]: -1} _LAST_ALL=$lastl nextnuml=00$((10#${lastl%%[^0-9]*} + 1)) nextnuml=${nextnuml: -3} _ALL_DISTRO=${nextnuml} fi fi # # if [ ! -f "/var/aegir/config/server_master/nginx/vhost.d/$_DOMAIN" ] ; then _DO_NOTHING=YES else msg "ERROR: Your defined domain: $_DOMAIN is already used on the Aegir Master Instance" msg "Please change the value for _DOMAIN to make it unique" msg "Bye" exit 1 fi # # if [ "$_DNS_SETUP_TEST" = "YES" ] ; then if [ -z "$_MY_OWNIP" ] ; then _THISHTIP=`ifconfig $_IFCONFIG | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'` if [[ "$_THISHTIP" =~ "127.0.0." ]] ; then _THISHTIP=`ifconfig ${_IFCONFIG}:0 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}'` fi else _THISHTIP="$_MY_OWNIP" fi _LOC_DOM="$_DOMAIN" find_correct_ip _THISRDIP="$_LOC_IP" if [ "$_THISRDIP" = "$_THISHTIP" ] ; then _DO_NOTHING=YES else msg "ERROR: Your defined domain: $_DOMAIN doesn't point to your IP: $_THISHTIP" msg "Please make sure you have valid IN A or IN CNAME record in your DNS" msg "It's also possible, that your DNS change didn't propagate yet" msg "Bye" exit 1 fi else if [ -z "$_MY_OWNIP" ] ; then _LOC_DOM="$_DOMAIN" find_correct_ip _THISHTIP="$_LOC_IP" _THISRDIP="$_LOC_IP" else _THISHTIP="$_MY_OWNIP" _THISRDIP="$_MY_OWNIP" fi fi # # if [ "$_PHP_FPM_VERSION" = "5.3" ] || [ "$_PHP_FPM_VERSION" = "5.4" ] || [ "$_PHP_FPM_VERSION" = "5.5" ] ; then _FPM_USED="both for D6 and D7 sites" else _FPM_USED="for D6, but 5.3 for D7 sites" fi echo " " msg "START -> checkpoint: " if [ "$_STATUS" = "INIT" ] ; then cat < /dev/null chattr +i /home/$1/platforms/* &> /dev/null if [ -d "/home/$1/.bazaar" ] ; then chattr +i /home/$1/.bazaar &> /dev/null fi chattr +i /home/$1/.drush &> /dev/null chattr +i /home/$1/.drush/*.ini &> /dev/null fi } # # Disable chattr. disable_chattr () { if [ ! -z "$1" ] && [ -d "/home/$1" ] ; then chattr -i /home/$1/platforms &> /dev/null chattr -i /home/$1/platforms/* &> /dev/null if [ -d "/home/$1/.bazaar" ] ; then chattr -i /home/$1/.bazaar &> /dev/null fi chattr -i /home/$1/.drush &> /dev/null chattr -i /home/$1/.drush/*.ini &> /dev/null fi } # msg "8s before we will continue..." sleep 8 rm -f /tmp/cache.inc* rm -f /opt/tmp/status-* rm -f -r /tmp/drush_make_tmp* rm -f -r /tmp/make_tmp* rm -f /tmp/pm-updatecode* if [ -e "/home/${_USER}.ftp" ] ; then disable_chattr ${_USER}.ftp fi action if [ -e "/home/${_USER}.ftp" ] ; then enable_chattr ${_USER}.ftp fi rm -f /tmp/cache.inc* rm -f -r /var/opt/* rm -f -r /opt/tmp/* rm -f -r /tmp/drush_make_tmp* rm -f -r /tmp/make_tmp* rm -f /tmp/pm-updatecode* rm -f /var/run/boa_run.pid exit 0 ###----------------------------------------### ### ### Octopus Aegir Installer ### Copyright (C) 2010-2014 Omega8.cc ### noc@omega8.cc www.omega8.cc ### ###----------------------------------------###