1313# Execute the script to install Odoo:
1414# ./odoo-install
1515# ###############################################################################
16- versiondate=" 2018-02-23a "
16+ versiondate=" 2018-02-26a "
1717
1818# #fixed parameters
1919OE_USER=" odoo"
@@ -67,6 +67,7 @@ domain="" # domain for let's encrypt https cert and nginx website.
6767_version=" False"
6868_livechatport=8072 # default live chat port. possibly already in use by other odoo instance.
6969_upgrade_python_libraries=" False"
70+ _sysvinit=" False" # default to False (therefore install systemd service). will be True (init.d service) if requested on command line.
7071
7172# ################################################################
7273# #### Values calculated at runtime - no need to modify these ####
@@ -76,6 +77,9 @@ _domain_exists="False"
7677_cores=$( grep processor /proc/cpuinfo | wc -l)
7778# ## let "_workers= $_cores * 2 + 1 "
7879let " _workers= $_cores + 1 "
80+ _totalkb=$( awk ' /^MemTotal:/{print $2}' /proc/meminfo) ;
81+ let " _totalmb= $_totalkb / 1024 "
82+ _diskfree=$( df -h $OE_HOME | tail -1 | tr -s ' ' | cut -d' ' -f4)
7983
8084# ############
8185# ## FUNCTIONS
@@ -90,7 +94,7 @@ function process_command_line {
9094 OPTIND=1
9195 OPTIONS=" EhuV"
9296 # Add single-letter options here. Uppercase lowercase is different. ":" means a parameter is expected with the option.
93- LONGOPTIONS=" enterprise,uninstall,self-update,update,upgrade,upgrade-python-libraries,help,delete-start-over,virtualenv,email:,domain:,nginx,version,livechatport:"
97+ LONGOPTIONS=" enterprise,uninstall,self-update,update,upgrade,upgrade-python-libraries,help,delete-start-over,virtualenv,email:,domain:,nginx,version,livechatport:,sysvinit "
9498 # Add comma-separated "long options" here. For example "--help". ":" means a parameter is expected with the option.
9599 PARSED=" $( getopt --options=$OPTIONS --longoptions=$LONGOPTIONS --name " $0 " -- " $@ " ) "
96100 if [[ $? -ne 0 ]]; then
@@ -156,6 +160,10 @@ function process_command_line {
156160 _virtualenv=" True"
157161 shift
158162 ;;
163+ --sysvinit)
164+ _sysvinit=" True"
165+ shift
166+ ;;
159167 --)
160168 shift
161169 break
@@ -454,7 +462,7 @@ function install_dependencies {
454462 build-essential libxml2 libxslt1.1 libxml2-dev libxslt1-dev \
455463 python-dev python-setuptools python3-setuptools \
456464 libxslt-dev libldap2-dev libsasl2-dev libssl-dev \
457- libgeoip-dev python-psycogreen \
465+ libgeoip-dev python-psycogreen libzip-dev \
458466 python-reportlab-accel python-zsi \
459467 python-openssl poppler-utils antiword >> $INSTALL_LOG
460468 # python-gevent python-dateutil python-feedparser python-ldap python-libxslt1
@@ -719,12 +727,39 @@ EOF
719727
720728function security_init_file {
721729 sudo mv ~ /$OE_CONFIG .tmp0 /etc/init.d/$OE_CONFIG >> $INSTALL_LOG
722- sudo chmod 755 /etc/init.d/$OE_CONFIG >> $INSTALL_LOG
730+ sudo chmod 0755 /etc/init.d/$OE_CONFIG >> $INSTALL_LOG
723731 sudo chown root: /etc/init.d/$OE_CONFIG >> $INSTALL_LOG
724732}
725733
726734function start_odoo_on_startup {
727735 sudo update-rc.d $OE_CONFIG defaults >> $INSTALL_LOG
736+ sudo systemctl enable $OE_CONFIG >> $INSTALL_LOG
737+ }
738+
739+ create_odoo_systemd_service () {
740+ cat << EOF > ~/${OE_CONFIG} .service
741+ [Unit]
742+ Description=$OE_CONFIG (Odoo $OE_VERSION $flavor )
743+ Requires=postgresql.service
744+ After=network.target postgresql.service
745+
746+ [Service]
747+ Type=simple
748+ SyslogIdentifier=$OE_CONFIG
749+ PermissionsStartOnly=true
750+ User=$OE_USER
751+ Group=$OE_USER
752+ #ExecStart=/opt/odoo/odoo11-venv/bin/python3 /opt/odoo/odoo11/odoo-bin -c /etc/odoo11.conf
753+ ExecStart=$( which python3) $OE_HOME_EXT /odoo-bin -c /etc/odoo/$OE_CONFIG .conf
754+ StandardOutput=journal+console
755+
756+ [Install]
757+ WantedBy=multi-user.target
758+ EOF
759+ sudo chmod 0644 ~ /${OE_CONFIG} .service >> $INSTALL_LOG
760+ sudo chown root:root ~ /${OE_CONFIG} .service >> $INSTALL_LOG
761+ sudo mv ~ /${OE_CONFIG} .service /etc/systemd/system/${OE_CONFIG} .service >> $INSTALL_LOG
762+ sudo systemctl enable ${OE_CONFIG} >> $INSTALL_LOG
728763}
729764
730765function start_odoo {
@@ -735,16 +770,21 @@ function show_odoo_status {
735770 sudo service ${OE_CONFIG} status
736771}
737772
738- function uninstall_odoo () {
739- # 1. Stop odoo-server "$OE_CONFIG" if running.
740- sudo service ${OE_CONFIG} stop
773+ function remove_sysvinit_service () {
741774 # 2. disable start odoo on startup.
742775 sudo update-rc.d ${OE_CONFIG} disable
743776 sudo update-rc.d ${OE_CONFIG} remove
744777 # 3. remove init file.
745778 sudo rm /etc/init.d/${OE_CONFIG}
746779 # 3b. clean up service daemon system settings.
747780 sudo systemctl daemon-reload
781+ }
782+
783+ function uninstall_odoo () {
784+ # 1. Stop odoo-server "$OE_CONFIG" if running.
785+ sudo service ${OE_CONFIG} stop
786+ # 2-3. Remove SysV Init service.
787+ remove_sysvinit_service
748788 # 4. remove /home/odoo/odoo-server dir (odoo community from github).
749789 sudo rm -r ${OE_HOME_EXT}
750790 # 4a. Remove downloaded wkhtmltox*
@@ -781,7 +821,11 @@ function show_help {
781821cd ~
782822# Clear previous odoo_install.log file to empty.
783823clear_install_log
784- echo " Odoo Installer version $versiondate , by Yenthe Van Ginneken and Chris Coleman (EspaceNetworks)."
824+ echo " Odoo Installer version $versiondate "
825+ echo " by Yenthe Van Ginneken and Chris Coleman (EspaceNetworks)."
826+ echo " System Memory detected: $_totalmb MB"
827+ echo " Free space on $OE_HOME : $_diskfree "
828+
785829command_line_args=" $@ "
786830process_command_line $command_line_args
787831if [[ $_version == " True" ]]; then
@@ -814,7 +858,7 @@ if [[ $_upgrade_python_libraries == "True" ]]; then
814858 upgrade_pip
815859 echo " d. Install upgraded python libraries"
816860 install_python_libraries
817- echo " Done."
861+ echo " e. Done, installed upgraded python libraries ."
818862 exit
819863fi
820864can_i_sudo
@@ -916,6 +960,7 @@ if [ $IS_ENTERPRISE == "True" ]; then
916960fi
917961
918962echo -e " ---- 14. Install npm nodejs less less-plugin-clean-css + shortcut ----"
963+ # These (npm nodejs less etc) are needed by enterprise AND community.
919964install_enterprise_libraries
920965
921966echo " ---- 15. Create custom module directory ----"
@@ -930,14 +975,23 @@ create_odoo_server_config_file
930975echo " 18. Create startup (shell command) file"
931976create_startup_file
932977
933- echo " 19. Create init (service) file"
934- create_odoo_init_file
935-
936- echo " 20. Security Init File"
937- security_init_file
938-
939- echo " 21. Start ODOO on Startup"
940- start_odoo_on_startup
978+ if [[ $_sysvinit == " True" ]]; then
979+ # OLD SYSV INIT SERVICE.
980+ echo " 19. Create init (service) file"
981+ create_odoo_init_file
982+ echo " 20. Security Init File"
983+ security_init_file
984+ echo " 21. Start ODOO on Startup"
985+ start_odoo_on_startup
986+ else
987+ # NEW SYSTEMD SERVICE
988+ echo " 18b. Remove old SysV Init service."
989+ set +e
990+ remove_sysvinit_service # clean up old sysv init service if it's there and we're installing over it.
991+ set -e
992+ echo " 19-21. Create systemd (service) file + Security systemd file + Start ODOO on startup"
993+ create_odoo_systemd_service
994+ fi
941995
942996echo " 22. Starting Odoo Service"
943997start_odoo
0 commit comments