2014-10-22 05:59:30 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2014-07-14 15:47:14 +00:00
|
|
|
set -e
|
|
|
|
|
2014-10-22 05:59:30 +00:00
|
|
|
|
|
|
|
## Utils
|
|
|
|
|
2014-11-05 06:15:00 +00:00
|
|
|
print_msg() {
|
|
|
|
echo "Frappe password: $FRAPPE_USER_PASS"
|
|
|
|
echo "MariaDB root password: $MSQ_PASS"
|
|
|
|
echo "Administrator password: $ADMIN_PASS"
|
|
|
|
}
|
|
|
|
|
|
|
|
get_passwd() {
|
|
|
|
echo `cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1`
|
|
|
|
}
|
|
|
|
|
2014-10-22 05:59:30 +00:00
|
|
|
set_opts () {
|
2015-03-09 13:42:10 +00:00
|
|
|
OPTS=`getopt -o v --long verbose,mysql-root-password:,frappe-user:,bench-branch:,setup-production,skip-setup-bench,help -n 'parse-options' -- "$@"`
|
2014-10-22 05:59:30 +00:00
|
|
|
|
|
|
|
if [ $? != 0 ] ; then echo "Failed parsing options." >&2 ; exit 1 ; fi
|
|
|
|
|
|
|
|
eval set -- "$OPTS"
|
|
|
|
|
|
|
|
VERBOSE=false
|
|
|
|
HELP=false
|
|
|
|
FRAPPE_USER=false
|
2014-11-25 18:39:35 +00:00
|
|
|
BENCH_BRANCH="master"
|
2014-11-05 06:15:00 +00:00
|
|
|
SETUP_PROD=false
|
2015-01-01 06:11:50 +00:00
|
|
|
SETUP_BENCH=true
|
2015-03-05 07:29:37 +00:00
|
|
|
|
|
|
|
if [ -f ~/frappe_passwords.sh ]; then
|
|
|
|
source ~/frappe_passwords.sh
|
|
|
|
else
|
|
|
|
FRAPPE_USER_PASS=`get_passwd`
|
|
|
|
MSQ_PASS=`get_passwd`
|
|
|
|
ADMIN_PASS=`get_passwd`
|
|
|
|
|
|
|
|
echo "FRAPPE_USER_PASS=$FRAPPE_USER_PASS" > ~/frappe_passwords.sh
|
|
|
|
echo "MSQ_PASS=$MSQ_PASS" >> ~/frappe_passwords.sh
|
|
|
|
echo "ADMIN_PASS=$ADMIN_PASS" >> ~/frappe_passwords.sh
|
|
|
|
fi
|
2014-10-22 05:59:30 +00:00
|
|
|
|
|
|
|
while true; do
|
|
|
|
case "$1" in
|
|
|
|
-v | --verbose ) VERBOSE=true; shift ;;
|
|
|
|
-h | --help ) HELP=true; shift ;;
|
|
|
|
--mysql-root-password ) MSQ_PASS="$2"; shift; shift ;;
|
|
|
|
--frappe-user ) FRAPPE_USER="$2"; shift; shift ;;
|
|
|
|
--setup-production ) SETUP_PROD=true; shift;;
|
2014-11-25 18:39:35 +00:00
|
|
|
--bench-branch ) BENCH_BRANCH="$2"; shift;;
|
2015-01-01 06:11:50 +00:00
|
|
|
--skip-setup-bench ) SETUP_BENCH=false; shift;;
|
2014-10-22 05:59:30 +00:00
|
|
|
-- ) shift; break ;;
|
|
|
|
* ) break ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2014-07-14 15:47:14 +00:00
|
|
|
get_distro() {
|
|
|
|
ARCH=$(uname -m | sed 's/x86_/amd/;s/i[3-6]86/x86/')
|
2014-11-11 05:16:55 +00:00
|
|
|
|
|
|
|
if [ $ARCH == "amd64" ]; then
|
|
|
|
T_ARCH="x86_64"
|
|
|
|
WK_ARCH="amd64"
|
|
|
|
else
|
|
|
|
T_ARCH="i386"
|
|
|
|
WK_ARCH="i386"
|
|
|
|
fi
|
|
|
|
|
2014-07-14 15:47:14 +00:00
|
|
|
if [ -f /etc/redhat-release ]; then
|
|
|
|
OS="centos"
|
2014-10-13 14:32:10 +00:00
|
|
|
OS_VER=`cat /etc/redhat-release | sed 's/Linux\ //g' | cut -d" " -f3 | cut -d. -f1`
|
2014-07-14 15:47:14 +00:00
|
|
|
|
|
|
|
elif [ -f /etc/lsb-release ]; then
|
|
|
|
. /etc/lsb-release
|
|
|
|
OS=$DISTRIB_ID
|
|
|
|
OS_VER=$DISTRIB_CODENAME
|
|
|
|
|
|
|
|
elif [ -f /etc/debian_version ]; then
|
|
|
|
. /etc/os-release
|
|
|
|
OS="debian" # XXX or Ubuntu??
|
|
|
|
OS_VER=$VERSION_ID
|
|
|
|
fi
|
|
|
|
|
|
|
|
export OS=$OS
|
|
|
|
export OS_VER=$OS_VER
|
|
|
|
export ARCH=$ARCH
|
2014-11-11 05:16:55 +00:00
|
|
|
export T_ARCH=$T_ARCH
|
|
|
|
export WK_ARCH=$WK_ARCH
|
2014-11-12 06:54:07 +00:00
|
|
|
echo Installing for $OS $OS_VER $ARCH
|
|
|
|
echo "In case you encounter an error, you can post on https://discuss.frappe.io"
|
2014-11-13 07:08:57 +00:00
|
|
|
echo
|
2014-07-14 15:47:14 +00:00
|
|
|
}
|
|
|
|
|
2014-10-22 05:59:30 +00:00
|
|
|
run_cmd() {
|
|
|
|
if $VERBOSE; then
|
|
|
|
"$@"
|
|
|
|
else
|
|
|
|
# $@
|
|
|
|
"$@" > /tmp/cmdoutput.txt 2>&1 || (cat /tmp/cmdoutput.txt && exit 1)
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
## add repos
|
|
|
|
|
|
|
|
add_centos6_mariadb_repo() {
|
2014-07-14 15:47:14 +00:00
|
|
|
echo "
|
|
|
|
[mariadb]
|
|
|
|
name = MariaDB
|
2015-04-22 09:11:27 +00:00
|
|
|
baseurl = http://yum.mariadb.org/10.0/centos$OS_VER-$ARCH
|
2014-07-14 15:47:14 +00:00
|
|
|
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
|
|
|
|
gpgcheck=1
|
|
|
|
" > /etc/yum.repos.d/mariadb.repo
|
|
|
|
}
|
2014-10-22 05:59:30 +00:00
|
|
|
|
2014-07-14 15:47:14 +00:00
|
|
|
|
|
|
|
add_ubuntu_mariadb_repo() {
|
2014-10-22 05:59:30 +00:00
|
|
|
run_cmd sudo apt-get update
|
2014-11-11 16:10:02 +00:00
|
|
|
run_cmd sudo apt-get install -y software-properties-common python-software-properties
|
2014-10-22 05:59:30 +00:00
|
|
|
run_cmd sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db
|
2015-04-22 09:11:27 +00:00
|
|
|
run_cmd sudo add-apt-repository "deb http://ams2.mirrors.digitalocean.com/mariadb/repo/10.0/ubuntu $OS_VER main"
|
2014-07-14 15:47:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
add_debian_mariadb_repo() {
|
|
|
|
if [ $OS_VER == "7" ]; then
|
|
|
|
CODENAME="wheezy"
|
|
|
|
|
|
|
|
elif [ $OS_VER == "6" ]; then
|
|
|
|
CODENAME="squeeze"
|
|
|
|
else
|
|
|
|
echo Unsupported Debian Version
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2014-10-22 05:59:30 +00:00
|
|
|
run_cmd sudo apt-get update
|
|
|
|
run_cmd sudo apt-get install -y python-software-properties
|
|
|
|
run_cmd sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xcbcb082a1bb943db
|
2015-04-22 09:11:27 +00:00
|
|
|
run_cmd sudo add-apt-repository "deb http://ams2.mirrors.digitalocean.com/mariadb/repo/10.0/debian $CODENAME main"
|
2014-10-22 05:59:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
add_ius_repo() {
|
|
|
|
if [ $OS_VER -eq "6" ]; then
|
|
|
|
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/$OS_VER/$T_ARCH/epel-release-6-5.noarch.rpm
|
|
|
|
wget http://dl.iuscommunity.org/pub/ius/stable/CentOS/$OS_VER/$T_ARCH/ius-release-1.0-13.ius.centos6.noarch.rpm
|
2014-11-11 05:16:55 +00:00
|
|
|
rpm --quiet -q epel-release || rpm -Uvh epel-release-6-5.noarch.rpm
|
|
|
|
rpm --quiet -q ius-release || rpm -Uvh ius-release-1.0-13.ius.centos6.noarch.rpm
|
2014-10-22 05:59:30 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
add_epel_centos7() {
|
|
|
|
yum install -y epel-release
|
2014-07-14 15:47:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
add_maria_db_repo() {
|
2014-12-04 07:51:23 +00:00
|
|
|
if [ "$OS" == "Ubuntu" ] && [ $OS_VER == "utopic" ]; then
|
2014-11-24 09:28:00 +00:00
|
|
|
return
|
|
|
|
elif [ "$OS" == "centos" ]; then
|
2014-11-11 05:16:55 +00:00
|
|
|
echo Adding centos mariadb repo
|
2014-10-22 05:59:30 +00:00
|
|
|
add_centos6_mariadb_repo
|
2014-07-14 15:47:14 +00:00
|
|
|
|
|
|
|
elif [ "$OS" == "debian" ]; then
|
2014-11-11 05:16:55 +00:00
|
|
|
echo Adding debian mariadb repo
|
2014-07-14 15:47:14 +00:00
|
|
|
add_debian_mariadb_repo
|
|
|
|
|
|
|
|
elif [ "$OS" == "Ubuntu" ]; then
|
2014-12-04 07:51:23 +00:00
|
|
|
echo Adding ubuntu mariadb repo
|
2014-07-14 15:47:14 +00:00
|
|
|
add_ubuntu_mariadb_repo
|
|
|
|
else
|
|
|
|
echo Unsupported Distribution
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-10-22 05:59:30 +00:00
|
|
|
## install
|
|
|
|
|
2014-07-14 15:47:14 +00:00
|
|
|
install_packages() {
|
2014-10-22 05:59:30 +00:00
|
|
|
if [ $OS == "centos" ]; then
|
|
|
|
run_cmd sudo yum install wget -y
|
|
|
|
run_cmd sudo yum groupinstall -y "Development tools"
|
|
|
|
if [ $OS_VER == "6" ]; then
|
|
|
|
run_cmd add_ius_repo
|
2015-05-21 06:46:12 +00:00
|
|
|
run_cmd sudo yum install -y git MariaDB-server MariaDB-client MariaDB-compat python-setuptools nginx zlib-devel bzip2-devel openssl-devel postfix python27-devel python27 libxml2 libxml2-devel libxslt libxslt-devel redis MariaDB-devel libXrender libXext python27-setuptools cronie sudo which xorg-x11-fonts-Type1 xorg-x11-fonts-75dpi
|
2014-10-22 05:59:30 +00:00
|
|
|
elif [ $OS_VER == "7" ]; then
|
|
|
|
run_cmd add_epel_centos7
|
2015-05-21 06:46:12 +00:00
|
|
|
run_cmd sudo yum install -y git mariadb-server mariadb-devel python-setuptools nginx zlib-devel bzip2-devel openssl-devel postfix python-devel libxml2 libxml2-devel libxslt libxslt-devel redis libXrender libXext supervisor cronie sudo which xorg-x11-fonts-75dpi xorg-x11-fonts-Type1
|
2014-10-22 05:59:30 +00:00
|
|
|
fi
|
2014-11-11 05:16:55 +00:00
|
|
|
echo "Installing wkhtmltopdf"
|
|
|
|
install_wkhtmltopdf_centos
|
2014-10-22 05:59:30 +00:00
|
|
|
run_cmd easy_install-2.7 -U pip
|
2014-07-14 15:47:14 +00:00
|
|
|
|
2014-10-13 14:32:10 +00:00
|
|
|
|
2014-10-22 05:59:30 +00:00
|
|
|
elif [ $OS == "debian" ] || [ $OS == "Ubuntu" ]; then
|
|
|
|
export DEBIAN_FRONTEND=noninteractive
|
|
|
|
setup_debconf
|
|
|
|
run_cmd sudo apt-get update
|
2015-05-21 06:46:12 +00:00
|
|
|
run_cmd sudo apt-get install python-dev python-setuptools build-essential python-mysqldb git ntp vim screen htop mariadb-server mariadb-common libmariadbclient-dev libxslt1.1 libxslt1-dev redis-server libssl-dev libcrypto++-dev postfix nginx supervisor python-pip fontconfig libxrender1 libxext6 xfonts-75dpi xfonts-base -y
|
2014-11-11 05:16:55 +00:00
|
|
|
echo "Installing wkhtmltopdf"
|
|
|
|
install_wkhtmltopdf_deb
|
2014-07-14 15:47:14 +00:00
|
|
|
|
|
|
|
else
|
|
|
|
echo Unsupported Distribution
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-11-11 05:16:55 +00:00
|
|
|
install_wkhtmltopdf_centos () {
|
|
|
|
|
2014-11-27 01:33:32 +00:00
|
|
|
if [[ $OS == "centos" && $OS_VER == "7" && $T_ARCH == "i386" ]]; then
|
2014-11-11 05:16:55 +00:00
|
|
|
echo "Cannot install wkhtmltodpdf. Skipping..."
|
|
|
|
return 0
|
|
|
|
fi
|
2015-01-20 07:02:22 +00:00
|
|
|
RPM="wkhtmltox-0.12.2.1_linux-$OS$OS_VER-$WK_ARCH.rpm"
|
2015-07-12 07:19:34 +00:00
|
|
|
run_cmd wget http://download.gna.org/wkhtmltopdf/0.12.2.1/$RPM
|
2014-11-11 05:16:55 +00:00
|
|
|
rpm --quiet -q wkhtmltox || run_cmd rpm -Uvh $RPM
|
|
|
|
}
|
|
|
|
|
|
|
|
install_wkhtmltopdf_deb () {
|
2015-05-20 09:03:20 +00:00
|
|
|
if [[ $OS_VER == "utopic" || $OS_VER == "vivid" ]]; then
|
2014-11-11 05:16:55 +00:00
|
|
|
echo "Cannot install wkhtmltodpdf. Skipping..."
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
if [[ $OS == "debian" && $OS_VER == "7" ]]; then
|
|
|
|
WK_VER="wheezy"
|
|
|
|
else
|
|
|
|
WK_VER=$OS_VER
|
|
|
|
fi
|
2015-07-12 07:07:13 +00:00
|
|
|
run_cmd wget http://download.gna.org/wkhtmltopdf/0.12.2.1/wkhtmltox-0.12.2.1_linux-$WK_VER-$WK_ARCH.deb
|
2015-01-20 07:02:22 +00:00
|
|
|
run_cmd dpkg -i wkhtmltox-0.12.2.1_linux-$WK_VER-$WK_ARCH.deb
|
2014-11-11 05:16:55 +00:00
|
|
|
}
|
|
|
|
|
2014-10-22 05:59:30 +00:00
|
|
|
|
|
|
|
install_supervisor_centos6() {
|
|
|
|
run_cmd easy_install supervisor
|
2014-11-11 05:16:55 +00:00
|
|
|
curl -Ss https://raw.githubusercontent.com/pdvyas/supervisor-initscripts/master/redhat-init-jkoppe > /etc/init.d/supervisord
|
|
|
|
curl -Ss https://raw.githubusercontent.com/pdvyas/supervisor-initscripts/master/redhat-sysconfig-jkoppe > /etc/sysconfig/supervisord
|
|
|
|
curl -Ss https://raw.githubusercontent.com/pdvyas/supervisor-initscripts/master/supervisord.conf > /etc/supervisord.conf
|
2014-10-22 05:59:30 +00:00
|
|
|
run_cmd mkdir /etc/supervisor.d
|
|
|
|
run_cmd chmod +x /etc/init.d/supervisord
|
|
|
|
bash -c "service supervisord start || true"
|
|
|
|
}
|
|
|
|
|
|
|
|
### config
|
|
|
|
|
|
|
|
get_mariadb_password() {
|
2014-10-22 06:45:41 +00:00
|
|
|
get_password "MariaDB root" MSQ_PASS
|
|
|
|
}
|
|
|
|
|
|
|
|
get_site_admin_password() {
|
|
|
|
get_password "Admin password" ADMIN_PASS
|
|
|
|
}
|
|
|
|
|
|
|
|
get_password() {
|
2014-11-05 06:15:00 +00:00
|
|
|
if [ -z "$2" ]; then
|
2014-10-22 05:59:30 +00:00
|
|
|
read -t 1 -n 10000 discard || true
|
|
|
|
echo
|
2014-10-22 06:45:41 +00:00
|
|
|
read -p "Enter $1 password to set:" -s TMP_PASS1
|
2014-10-22 05:59:30 +00:00
|
|
|
echo
|
2014-10-22 06:45:41 +00:00
|
|
|
read -p "Re enter $1 password to set:" -s TMP_PASS2
|
2014-10-22 05:59:30 +00:00
|
|
|
echo
|
2014-10-22 06:45:41 +00:00
|
|
|
if [ $TMP_PASS1 == $TMP_PASS2 ]; then
|
2014-11-14 15:20:33 +00:00
|
|
|
export $2=$TMP_PASS1
|
2014-10-22 05:59:30 +00:00
|
|
|
else
|
|
|
|
echo Passwords do not match
|
2014-10-22 06:45:41 +00:00
|
|
|
get_password $1 $2
|
2014-10-22 05:59:30 +00:00
|
|
|
fi
|
2014-07-14 15:47:14 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
configure_mariadb_centos() {
|
|
|
|
# Required only for CentOS, Ubuntu and Debian will show dpkg configure screen to set the password
|
|
|
|
if [ $OS == "centos" ]; then
|
|
|
|
mysqladmin -u root password $MSQ_PASS
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-11-11 05:16:55 +00:00
|
|
|
start_services_centos6() {
|
|
|
|
run_cmd service nginx start
|
|
|
|
run_cmd service mysql start
|
|
|
|
run_cmd service redis start
|
2014-07-14 15:47:14 +00:00
|
|
|
}
|
|
|
|
|
2014-10-22 05:59:30 +00:00
|
|
|
configure_services_centos6() {
|
|
|
|
run_cmd chkconfig --add supervisord
|
|
|
|
run_cmd chkconfig redis on
|
|
|
|
run_cmd chkconfig mysql on
|
|
|
|
run_cmd chkconfig nginx on
|
|
|
|
run_cmd chkconfig supervisord on
|
2014-07-14 15:47:14 +00:00
|
|
|
}
|
|
|
|
|
2014-10-13 14:32:10 +00:00
|
|
|
configure_services_centos7() {
|
2014-10-22 05:59:30 +00:00
|
|
|
run_cmd systemctl enable nginx
|
2015-01-10 17:11:59 +00:00
|
|
|
run_cmd systemctl enable mysql
|
2014-10-22 05:59:30 +00:00
|
|
|
run_cmd systemctl enable redis
|
|
|
|
run_cmd systemctl enable supervisord
|
2014-10-13 14:32:10 +00:00
|
|
|
}
|
|
|
|
|
2014-10-22 05:59:30 +00:00
|
|
|
start_services_centos7() {
|
|
|
|
run_cmd systemctl start nginx
|
2015-01-10 17:11:59 +00:00
|
|
|
run_cmd systemctl start mysql
|
2014-10-22 05:59:30 +00:00
|
|
|
run_cmd systemctl start redis
|
|
|
|
run_cmd systemctl start supervisord
|
2014-07-14 15:47:14 +00:00
|
|
|
}
|
|
|
|
|
2015-03-26 03:26:28 +00:00
|
|
|
configure_mariadb() {
|
|
|
|
config="
|
|
|
|
[mysqld]
|
|
|
|
innodb-file-format=barracuda
|
|
|
|
innodb-file-per-table=1
|
|
|
|
innodb-large-prefix=1
|
|
|
|
character-set-client-handshake = FALSE
|
|
|
|
character-set-server = utf8mb4
|
|
|
|
collation-server = utf8mb4_unicode_ci
|
|
|
|
|
|
|
|
[mysql]
|
|
|
|
default-character-set = utf8mb4
|
|
|
|
"
|
|
|
|
deb_cnf_path="/etc/mysql/conf.d/barracuda.cnf"
|
|
|
|
centos_cnf_path="/etc/my.cnf.d/barracuda.cnf"
|
|
|
|
|
|
|
|
if [ $OS == "centos" ]; then
|
|
|
|
|
|
|
|
echo "$config" > $centos_cnf_path
|
|
|
|
if [ $OS_VER == "6" ]; then
|
|
|
|
run_cmd sudo service mysql restart
|
|
|
|
elif [ $OS_VER == "7" ]; then
|
|
|
|
run_cmd sudo systemctl restart mysql
|
|
|
|
fi
|
|
|
|
|
|
|
|
elif [ $OS == "debian" ] || [ $OS == "Ubuntu" ]; then
|
|
|
|
echo "$config" > $deb_cnf_path
|
|
|
|
sudo service mysql restart
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-10-22 05:59:30 +00:00
|
|
|
setup_debconf() {
|
|
|
|
debconf-set-selections <<< "postfix postfix/mailname string `hostname`"
|
|
|
|
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'Internet Site'"
|
|
|
|
debconf-set-selections <<< "mariadb-server-5.5 mysql-server/root_password password $MSQ_PASS"
|
|
|
|
debconf-set-selections <<< "mariadb-server-5.5 mysql-server/root_password_again password $MSQ_PASS"
|
2014-10-13 14:32:10 +00:00
|
|
|
}
|
|
|
|
|
2014-07-14 15:47:14 +00:00
|
|
|
install_bench() {
|
2014-11-25 18:39:35 +00:00
|
|
|
run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER && git clone https://github.com/frappe/bench --branch $BENCH_BRANCH bench-repo"
|
2014-11-25 17:25:27 +00:00
|
|
|
if hash pip-2.7 &> /dev/null; then
|
2014-07-14 15:47:14 +00:00
|
|
|
PIP="pip-2.7"
|
2014-11-25 17:25:27 +00:00
|
|
|
elif hash pip2.7 &> /dev/null; then
|
2014-07-14 15:47:14 +00:00
|
|
|
PIP="pip2.7"
|
2014-11-25 17:25:27 +00:00
|
|
|
elif hash pip2 &> /dev/null; then
|
2014-07-14 15:47:14 +00:00
|
|
|
PIP="pip2"
|
2014-11-25 17:25:27 +00:00
|
|
|
elif hash pip &> /dev/null; then
|
2014-07-14 15:47:14 +00:00
|
|
|
PIP="pip"
|
|
|
|
else
|
|
|
|
echo PIP not installed
|
|
|
|
exit 1
|
|
|
|
fi
|
2014-10-22 05:59:30 +00:00
|
|
|
run_cmd sudo $PIP install -e /home/$FRAPPE_USER/bench-repo
|
2014-07-14 15:47:14 +00:00
|
|
|
}
|
|
|
|
|
2014-10-22 05:59:30 +00:00
|
|
|
setup_bench() {
|
|
|
|
echo Installing frappe-bench
|
2015-03-16 13:00:15 +00:00
|
|
|
FRAPPE_BRANCH="develop"
|
|
|
|
ERPNEXT_APPS_JSON="https://raw.githubusercontent.com/frappe/bench/master/install_scripts/erpnext-apps.json"
|
2014-11-11 05:16:55 +00:00
|
|
|
if $SETUP_PROD; then
|
|
|
|
FRAPPE_BRANCH="master"
|
|
|
|
ERPNEXT_APPS_JSON="https://raw.githubusercontent.com/frappe/bench/master/install_scripts/erpnext-apps-master.json"
|
|
|
|
fi
|
|
|
|
|
|
|
|
run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER && bench init frappe-bench --frappe-branch $FRAPPE_BRANCH --apps_path $ERPNEXT_APPS_JSON"
|
2014-10-22 06:45:41 +00:00
|
|
|
echo Setting up first site
|
2014-11-11 05:16:55 +00:00
|
|
|
echo /home/$FRAPPE_USER/frappe-bench > /etc/frappe_bench_dir
|
2014-11-05 06:15:00 +00:00
|
|
|
run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench new-site site1.local --mariadb-root-password $MSQ_PASS --admin-password $ADMIN_PASS"
|
2015-05-20 04:29:18 +00:00
|
|
|
run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench install-app erpnext"
|
2014-11-05 06:15:00 +00:00
|
|
|
run_cmd bash -c "cd /home/$FRAPPE_USER/frappe-bench && bench setup sudoers $FRAPPE_USER"
|
|
|
|
if $SETUP_PROD; then
|
2014-11-18 10:37:46 +00:00
|
|
|
run_cmd bash -c "cd /home/$FRAPPE_USER/frappe-bench && bench setup production $FRAPPE_USER"
|
2014-11-05 06:15:00 +00:00
|
|
|
fi
|
2015-05-06 04:44:51 +00:00
|
|
|
chown $FRAPPE_USER /home/$FRAPPE_USER/frappe-bench/logs/*
|
2014-10-22 05:59:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
add_user() {
|
|
|
|
# Check if script is running as root and is not running as sudo. We want to skip
|
|
|
|
# this step if the user is already running this script with sudo as a non root
|
|
|
|
# user
|
|
|
|
if [ "$FRAPPE_USER" == "false" ]; then
|
2014-11-05 06:15:00 +00:00
|
|
|
if [[ $SUDO_UID -eq 0 ]] && [[ $EUID -eq 0 ]]; then
|
2014-10-22 05:59:30 +00:00
|
|
|
export FRAPPE_USER="frappe"
|
|
|
|
else
|
|
|
|
export FRAPPE_USER="$SUDO_USER"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
USER_EXISTS=`bash -c "id $FRAPPE_USER > /dev/null 2>&1 && echo true || (echo false && exit 0)"`
|
|
|
|
|
|
|
|
if [ $USER_EXISTS == "false" ]; then
|
|
|
|
useradd -m -d /home/$FRAPPE_USER -s $SHELL $FRAPPE_USER
|
2014-11-05 06:15:00 +00:00
|
|
|
echo $FRAPPE_USER:$FRAPPE_USER_PASS | chpasswd
|
2014-10-22 05:59:30 +00:00
|
|
|
chmod o+x /home/$FRAPPE_USER
|
|
|
|
chmod o+r /home/$FRAPPE_USER
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2014-11-05 06:15:00 +00:00
|
|
|
main() {
|
|
|
|
set_opts $@
|
|
|
|
get_distro
|
|
|
|
add_maria_db_repo
|
|
|
|
echo Installing packages for $OS\. This might take time...
|
|
|
|
install_packages
|
|
|
|
if [ $OS == "centos" ]; then
|
|
|
|
if [ $OS_VER == "6" ]; then
|
|
|
|
echo "Installing supervisor"
|
|
|
|
install_supervisor_centos6
|
|
|
|
echo "Configuring CentOS services"
|
|
|
|
configure_services_centos6
|
|
|
|
echo "Starting services"
|
|
|
|
start_services_centos6
|
|
|
|
elif [ $OS_VER == "7" ]; then
|
|
|
|
echo "Configuring CentOS services"
|
|
|
|
configure_services_centos7
|
|
|
|
echo "Starting services"
|
|
|
|
start_services_centos7
|
|
|
|
fi
|
2014-11-11 05:16:55 +00:00
|
|
|
configure_mariadb_centos
|
2014-10-22 05:59:30 +00:00
|
|
|
fi
|
2015-03-26 03:26:28 +00:00
|
|
|
configure_mariadb
|
2014-11-05 06:15:00 +00:00
|
|
|
echo "Adding frappe user"
|
|
|
|
add_user
|
|
|
|
install_bench
|
2015-01-01 06:11:50 +00:00
|
|
|
if $SETUP_BENCH; then
|
|
|
|
setup_bench
|
|
|
|
fi
|
2014-11-11 05:16:55 +00:00
|
|
|
|
|
|
|
echo
|
2014-11-12 06:54:07 +00:00
|
|
|
RUNNING=""
|
|
|
|
if $SETUP_PROD; then
|
|
|
|
RUNNING=" and is running on port 80"
|
|
|
|
fi
|
|
|
|
echo "Frappe/ERPNext is installed successfully$RUNNING."
|
2014-11-11 05:16:55 +00:00
|
|
|
print_msg > ~/frappe_passwords.txt
|
2014-11-05 06:15:00 +00:00
|
|
|
print_msg
|
2014-11-11 05:16:55 +00:00
|
|
|
echo
|
|
|
|
echo "The passwords are also stored at ~/frappe_passwords.txt"
|
|
|
|
echo "You can remove this file after making a note of the passwords."
|
2014-11-05 06:15:00 +00:00
|
|
|
}
|
|
|
|
|
2014-11-11 05:16:55 +00:00
|
|
|
main $@
|