From 388a3958030581cb9b19dd709bbef917677419cf Mon Sep 17 00:00:00 2001 From: Pratik Vyas Date: Tue, 11 Nov 2014 10:46:55 +0530 Subject: [PATCH] fix install script --- install_scripts/setup_frappe.sh | 95 ++++++++++++++++++++++++--------- 1 file changed, 71 insertions(+), 24 deletions(-) diff --git a/install_scripts/setup_frappe.sh b/install_scripts/setup_frappe.sh index ef5bcd83..6c6fdada 100644 --- a/install_scripts/setup_frappe.sh +++ b/install_scripts/setup_frappe.sh @@ -6,7 +6,6 @@ set -e ## Utils print_msg() { - echo "Frappe/ERPNext is installed successfully." echo "Frappe password: $FRAPPE_USER_PASS" echo "MariaDB root password: $MSQ_PASS" echo "Administrator password: $ADMIN_PASS" @@ -46,6 +45,15 @@ set_opts () { get_distro() { ARCH=$(uname -m | sed 's/x86_/amd/;s/i[3-6]86/x86/') + + if [ $ARCH == "amd64" ]; then + T_ARCH="x86_64" + WK_ARCH="amd64" + else + T_ARCH="i386" + WK_ARCH="i386" + fi + if [ -f /etc/redhat-release ]; then OS="centos" OS_VER=`cat /etc/redhat-release | sed 's/Linux\ //g' | cut -d" " -f3 | cut -d. -f1` @@ -64,7 +72,9 @@ get_distro() { export OS=$OS export OS_VER=$OS_VER export ARCH=$ARCH - echo DEBUG $OS $OS_VER $ARCH + export T_ARCH=$T_ARCH + export WK_ARCH=$WK_ARCH + echo DEBUG $OS $OS_VER $ARCH $WK_ARCH } run_cmd() { @@ -114,16 +124,11 @@ add_debian_mariadb_repo() { } add_ius_repo() { - if [ $ARCH == "amd64" ]; then - T_ARCH="x86_64" - else - T_ARCH="i386" - fi 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 - rpm -Uvh epel-release-6-5.noarch.rpm - rpm -Uvh ius-release-1.0-13.ius.centos6.noarch.rpm + 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 fi } @@ -133,15 +138,15 @@ add_epel_centos7() { add_maria_db_repo() { if [ "$OS" == "centos" ]; then - echo DEBUG adding centos mariadb repo + echo Adding centos mariadb repo add_centos6_mariadb_repo elif [ "$OS" == "debian" ]; then - echo DEBUG adding debian mariadb repo + echo Adding debian mariadb repo add_debian_mariadb_repo elif [ "$OS" == "Ubuntu" ]; then - echo DEBUG adding debian mariadb repo + echo Adding debian mariadb repo add_ubuntu_mariadb_repo else echo Unsupported Distribution @@ -162,8 +167,8 @@ install_packages() { run_cmd add_epel_centos7 run_cmd sudo yum install -y git mariadb-server mariadb-devel python-setuptools nginx zlib-devel bzip2-devel openssl-devel memcached postfix python-devel libxml2 libxml2-devel libxslt libxslt-devel redis libXrender libXext supervisor fi - run_cmd wget http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.1/wkhtmltox-0.12.1_linux-centos6-amd64.rpm - run_cmd sudo rpm -Uvh wkhtmltox-0.12.1_linux-centos6-amd64.rpm + echo "Installing wkhtmltopdf" + install_wkhtmltopdf_centos run_cmd easy_install-2.7 -U pip @@ -172,6 +177,8 @@ install_packages() { setup_debconf run_cmd sudo apt-get update run_cmd sudo apt-get install python-dev python-setuptools build-essential python-mysqldb git memcached 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 -y + echo "Installing wkhtmltopdf" + install_wkhtmltopdf_deb else echo Unsupported Distribution @@ -179,12 +186,37 @@ install_packages() { fi } +install_wkhtmltopdf_centos () { + + if [[ $OS == "centos" && $OS_VER == "7" && $T_ARCH="i386" ]]; then + echo "Cannot install wkhtmltodpdf. Skipping..." + return 0 + fi + RPM="wkhtmltox-0.12.1_linux-$OS$OS_VER-$WK_ARCH.rpm" + run_cmd wget http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.1/$RPM + rpm --quiet -q wkhtmltox || run_cmd rpm -Uvh $RPM +} + +install_wkhtmltopdf_deb () { + if [[ $OS_VER == "utopic" ]]; then + echo "Cannot install wkhtmltodpdf. Skipping..." + return 0 + fi + if [[ $OS == "debian" && $OS_VER == "7" ]]; then + WK_VER="wheezy" + else + WK_VER=$OS_VER + fi + run_cmd wget http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.1/wkhtmltox-0.12.1_linux-$WK_VER-$WK_ARCH.deb + run_cmd dpkg -i wkhtmltox-0.12.1_linux-$WK_VER-$WK_ARCH.deb +} + install_supervisor_centos6() { run_cmd easy_install supervisor - run_cmd curl https://raw.githubusercontent.com/pdvyas/supervisor-initscripts/master/redhat-init-jkoppe > /etc/init.d/supervisord - run_cmd curl https://raw.githubusercontent.com/pdvyas/supervisor-initscripts/master/redhat-sysconfig-jkoppe > /etc/sysconfig/supervisord - run_cmd curl https://raw.githubusercontent.com/pdvyas/supervisor-initscripts/master/supervisord.conf > /etc/supervisord.conf + 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 run_cmd mkdir /etc/supervisor.d run_cmd chmod +x /etc/init.d/supervisord bash -c "service supervisord start || true" @@ -224,11 +256,10 @@ configure_mariadb_centos() { fi } -start_services_centos() { - run_cmd systemctl start nginx - run_cmd systemctl start mariadb - run_cmd systemctl start redis - run_cmd systemctl start supervisord +start_services_centos6() { + run_cmd service nginx start + run_cmd service mysql start + run_cmd service redis start } configure_services_centos6() { @@ -284,8 +315,16 @@ install_bench() { setup_bench() { echo Installing frappe-bench - run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER && bench init frappe-bench --apps_path https://raw.githubusercontent.com/frappe/bench/master/install_scripts/erpnext-apps.json" + FRAPPE_BRANCH="develop" + ERPNEXT_APPS_JSON="https://raw.githubusercontent.com/frappe/bench/master/install_scripts/erpnext-apps.json" + 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" echo Setting up first site + echo /home/$FRAPPE_USER/frappe-bench > /etc/frappe_bench_dir 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" run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench frappe --install_app erpnext" run_cmd sudo su $FRAPPE_USER -c "cd /home/$FRAPPE_USER/frappe-bench && bench frappe --install_app shopping_cart" @@ -337,12 +376,20 @@ main() { echo "Starting services" start_services_centos7 fi + configure_mariadb_centos fi echo "Adding frappe user" add_user install_bench setup_bench + + echo + echo "Frappe/ERPNext is installed successfully." + print_msg > ~/frappe_passwords.txt print_msg + echo + echo "The passwords are also stored at ~/frappe_passwords.txt" + echo "You can remove this file after making a note of the passwords." } -main +main $@