From 439239b36500d70cb40433066e32354823c91985 Mon Sep 17 00:00:00 2001 From: neher-igel Date: Tue, 17 Sep 2024 16:53:33 -0600 Subject: [PATCH] zoho assist post installer zoho assist post installer --- .../Zoho_Assist/build/build-zohoassist-cp.sh | 3 +- .../Apps/Zoho_Assist/build/igel_postinst.sh | 106 ++++++++++++++++++ 2 files changed, 108 insertions(+), 1 deletion(-) create mode 100755 CP_Source/Apps/Zoho_Assist/build/igel_postinst.sh diff --git a/CP_Source/Apps/Zoho_Assist/build/build-zohoassist-cp.sh b/CP_Source/Apps/Zoho_Assist/build/build-zohoassist-cp.sh index b7f2160c..f73563fd 100755 --- a/CP_Source/Apps/Zoho_Assist/build/build-zohoassist-cp.sh +++ b/CP_Source/Apps/Zoho_Assist/build/build-zohoassist-cp.sh @@ -96,6 +96,7 @@ if [ "${APPARMOR}" = "TRUE" ]; then mv custom/target/build/igel-${CP}-cp-apparmor-reload.service custom/${CP}/lib/systemd/system/ fi mv custom/target/build/${CP}-cp-init-script.sh custom +mv custom/target/build/igel_postinst.sh custom/${CP}/usr/local/ZohoAssist cd custom @@ -106,7 +107,7 @@ ar -x ${GETVERSION_FILE} tar xf control.tar* VERSION=$(grep Version control | cut -d " " -f 2) # copy postinst to CP -cp postinst ../${CP}/usr/local/ZohoAssist/igel_postinst.sh +#cp postinst ../${CP}/usr/local/ZohoAssist/igel_postinst.sh #echo "Version is: " ${VERSION} cd .. sed -i "/^version=/c version=\"${VERSION}\"" target/${CP}.inf diff --git a/CP_Source/Apps/Zoho_Assist/build/igel_postinst.sh b/CP_Source/Apps/Zoho_Assist/build/igel_postinst.sh new file mode 100755 index 00000000..e66785d4 --- /dev/null +++ b/CP_Source/Apps/Zoho_Assist/build/igel_postinst.sh @@ -0,0 +1,106 @@ +#!/bin/bash +set -x +trap read debug + +SERVICE_APPLICATION_PATH=/usr/local/ZohoAssist/Service/ZohoAssistURS +ZOHO_UNATTENDED_PATH=/usr/local/ZohoAssist/Service/ZohoAssistUnattended +SERVICE_SCRIPT_PATH=/usr/local/ZohoAssist/Service/ZohoAssistUrs +SYSTEMD_SCRIPT_PATH=/usr/local/ZohoAssist/Service/ZohoAssistUrs.service +SCREEN_SHARING_APPLICATION=/usr/local/ZohoAssist/bin/main +ANNOTATION=/usr/local/ZohoAssist/bin/Annotation +UI=/usr/local/ZohoAssist/bin/ZohoAssist +TRAY_ICON=/usr/local/ZohoAssist/bin/TrayIcon +TOOLS=/usr/local/ZohoAssist/bin/zsysmanager +ACTIVEDISPLAY=/usr/local/ZohoAssist/bin/activeDisplay + +BIN_PATH=/usr/bin + +serviceType=$(ls -al /proc/1/exe | awk -F' ' '{print $NF}' | awk -F'/' '{print $NF}') + + +main() +{ + enableExecutablePrivilege + configureComputer +} + +CreateLogsDir() +{ + if ! [ -d "/var/log/ZohoAssist" ]; then + mkdir /var/log/ZohoAssist + fi +} + +enableExecutablePrivilege() +{ +chmod +x $ZOHO_UNATTENDED_PATH +chmod +x $SERVICE_APPLICATION_PATH +chmod +x $SCREEN_SHARING_APPLICATION +chmod +x $ANNOTATION +chmod +x $UI +chmod +x $SERVICE_SCRIPT_PATH +chmod +x $TRAY_ICON +chmod +x /usr/local/ZohoAssist/bin/zwin +chmod +x /usr/local/ZohoAssist/Upgrader/ZohoAssistUpgrader +chmod +x $TOOLS +chmod +x $ACTIVEDISPLAY +} + + +configureComputer() +{ + + if [ ! -f /custom/zohoassist/usr/local/ZohoAssist/igel_installed.txt ]; then + touch /custom/zohoassist/usr/local/ZohoAssist/igel_installed.txt + $ZOHO_UNATTENDED_PATH -stype "${serviceType}" -cmd "install" + echo "application configured" + fi + + CreateLogsDir + createSymLinks + updateCron + updateService + su $(logname) bash -c `TrayIcon -p urs` & echo "" +} + +createSymLinks() +{ +ln -s $TRAY_ICON $BIN_PATH +ln -s /usr/local/ZohoAssist/bin/ZohoAssist.desktop /etc/xdg/autostart +cp /usr/local/ZohoAssist/Upgrader/zohoassist /etc/cron.d +} + +updateService() +{ + if [ "systemd" == "${serviceType}" ]; then + echo "installing systemctl service" + cp $SYSTEMD_SCRIPT_PATH /etc/systemd/system/ + systemctl enable ZohoAssistUrs.service + systemctl daemon-reload + systemctl start ZohoAssistUrs.service + elif [ "init" == "${serviceType}" ]; then + echo "installing systemV service" + serviceType="initv" + ln -s $SERVICE_APPLICATION_PATH $BIN_PATH + ln -s $SERVICE_SCRIPT_PATH /etc/init.d/ + update-rc.d ZohoAssistUrs defaults + update-rc.d ZohoAssistUrs enable + setsid $SERVICE_APPLICATION_PATH >/dev/null 2>&1 < /dev/null & + fi +} + +updateCron() +{ + echo "reloading cron" + service cron reload + + if (systemctl -q is-enabled crond.service) + then + systemctl restart crond.service + else + systemctl restart cron.service + fi +} + + +main $*