#!/bin/bash ACTION="$1" shift PACKAGE_LIST=$@ # START Define variables DESTDOWNLOAD="/var/cache/epi-downloads" KEME_DEB="keme-amd64.deb" KEME_URL="https://downloads.sourceforge.net/project/keme/KEME-Contabilidad/3.2.0.3/keme-3.2.0.3-Ubuntu-18.04-64bits.deb?r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fkeme%2Ffiles%2FKEME-Contabilidad%2F3.2.0.3%2Fkeme-3.2.0.3-Ubuntu-18.04-64bits.deb%2Fdownload%3Fuse_mirror%3Dmaster%26r%3Dhttps%253A%252F%252Fwww.google.com%252F%26use_mirror%3Dmaster&ts=1591194005" KEME_MD5="662d04995488b49db98c7c2084a7d742" # END Define Variables case $ACTION in getStatus) #START KEME if [[ " ${PACKAGE_LIST[*]} " == *" keme "* ]]; then if dpkg -s keme-contabilidad >/dev/null 2>&1 ;then echo 0 else echo 1 fi elif [[ " ${PACKAGE_LIST[*]} " == *" odoo "* ]]; then if [ -n "$(docker images -q postgres:10)" -a -n $(docker images -q odoo:latest) -a -f "/usr/bin/odoorun" -a -f "/usr/share/polkit-1/actions/net.lliurex.odoorun.policy" ] ;then echo 0 else echo 1 fi else echo "Not found" fi #END KEME ;; download) #START KEME Script if [[ " ${PACKAGE_LIST[*]} " == *" keme "* ]]; then echo "Downloading KEME ... please wait" cd ${DESTDOWNLOAD} if [ -s ${DESTDOWNLOAD}"/"${KEME_DEB} ] then rm -f ${DESTDOWNLOAD}"/"${KEME_DEB} fi wget -O ${KEME_DEB} ${KEME_URL} MD5=$(md5sum "${DESTDOWNLOAD}/${KEME_DEB}"|cut -d' ' -f1) if [ "x${KEME_MD5}" = "x${MD5}" -a -s "${DESTDOWNLOAD}/${KEME_DEB}" ];then echo "KEME installed successfully" else echo "Error donwloading KEME project.... please contact with LliureX Team in www.lliurex.net" exit 1 fi fi #END KEME Script ;; preInstall) #START KEME if [[ " ${PACKAGE_LIST[*]} " == *" keme "* ]]; then echo "****PreInstalling keme plugins... please wait****" apt install gdebi-core -y echo " * * Finished * * " fi #END KEME ;; installPackage) #START KEME if [[ " ${PACKAGE_LIST[*]} " == *" keme "* ]]; then echo "****Installing KEME Suite... please wait****" gdebi ${DESTDOWNLOAD}"/"${KEME_DEB} -n echo " * * Finished * * " fi #END KEME #START ODOO if [[ " ${PACKAGE_LIST[*]} " == *" odoo "* ]]; then echo "****Installing Odoo 13 & Postgres dockers... please wait****" docker image pull postgres:10 docker image pull odoo inst="$(docker ps -a -q -f ancestor=odoo)" if [ -n "${inst}" ]; then docker rm -f "${inst}" fi inst="$(docker ps -a -q -f ancestor=postgres:10)" if [ -n "${inst}" ]; then docker rm -f "${inst}" fi cp /usr/share/zero-fp-administrativo/odoo.desktop /usr/share/applications/ cp /usr/share/zero-fp-administrativo/odoo.png /usr/share/icons cp /usr/share/zero-fp-administrativo/odoorun /usr/bin/odoorun cp /usr/share/zero-fp-administrativo/net.lliurex.odoorun.policy /usr/share/polkit-1/actions/ chmod +x /usr/bin/odoorun systemctl restart polkit echo " * * Finished * * " fi #END ODOO ;; remove) for ix in $PACKAGE_LIST do #START KEME if [[ " $ix " == *" keme "* ]]; then if dpkg -s keme-contabilidad >/dev/null 2>&1 ;then echo "****Unstalling KEME Suite... please wait****" apt-get remove -y keme-contabilidad echo " * * Finished * * " fi #END KEME #START ODOO elif [[ " $ix " == *" odoo "* ]]; then echo "****Uninstalling Odoo 13 & Postgres dockers... please wait****" inst="$(docker ps -a -q -f ancestor=odoo)" if [ -n "${inst}" ]; then docker rm -f "${inst}" fi inst="$(docker ps -a -q -f ancestor=postgres:10)" if [ -n "${inst}" ]; then docker rm -f "${inst}" fi imgs="$(docker images -q odoo:latest)" if [ -n "${imgs}" ];then docker rmi "${imgs}" fi imgs="$(docker images -q postgres:10)" if [ -n "${imgs}"];then docker rmi "${imgs}" fi rm -f /usr/share/applications/odoo.desktop rm -f /usr/share/icons/odoo.png rm -f /usr/bin/odoorun rm -f /usr/share/polkit-1/actions/net.lliurex.odoorun.policy systemctl restart polkit echo " * * Finished * * " #END ODOO else apt-get remove -y $ix TEST=$( dpkg-query -s $ix 2> /dev/null| grep Status | cut -d " " -f 4 ) if [ "$TEST" == 'installed' ];then exit 1 fi fi done ;; esac exit 0