summarylogtreecommitdiffstats
path: root/forticlient-vpn.install
diff options
context:
space:
mode:
authorDouglas Iuri Medeiros Cabral2022-11-12 11:42:24 -0300
committerDouglas Iuri Medeiros Cabral2022-11-12 11:42:24 -0300
commit94595fa6a614294cb816b64036767ed4c49183a7 (patch)
treed256cf4008f9fff5d6169e876f969d1c8f9e6f95 /forticlient-vpn.install
parent16cb932027e0e53360cbe6601e5e4052eb69a680 (diff)
downloadaur-94595fa6a614294cb816b64036767ed4c49183a7.tar.gz
Added systemd to depends and improves the install script
Diffstat (limited to 'forticlient-vpn.install')
-rw-r--r--forticlient-vpn.install159
1 files changed, 108 insertions, 51 deletions
diff --git a/forticlient-vpn.install b/forticlient-vpn.install
index 567b72391f52..20b7504c58d6 100644
--- a/forticlient-vpn.install
+++ b/forticlient-vpn.install
@@ -27,83 +27,110 @@ pre_install () {
}
pre_upgrade () {
-# Remove old symlink when upgrading from older versions
-if [ -f /usr/bin/FortiClient ]; then
- pkill -f /usr/bin/FortiClient
- rm -rf /usr/bin/FortiClient
-fi
+ # Check if forticlient is registered to EMS if it's an uninstall
+ if [ -f /opt/forticlient/.fct_ec_registered ]; then
+ echo "Error: Unable to uninstall forticlient while connected to EMS"
+ exit 1
+ fi
+
+ # Remove old symlink when upgrading from older versions
+ if [ -f /usr/bin/FortiClient ]; then
+ pkill -f /usr/bin/FortiClient
+ rm -rf /usr/bin/FortiClient
+ fi
}
post_install() {
# Remove older version directories and files when upgrading
if [ -d /usr/bin/forticlient ]; then
- pkill -f /usr/bin/forticlient
- rm -rf /usr/bin/forticlient
+ pkill -f /usr/bin/forticlient
+ rm -rf /usr/bin/forticlient
fi
# Remove old configuration files when upgrading from older versions
if [ -f /etc/forticlient/config.xml ]; then
- rm -rf /etc/forticlient/config.xml
+ rm -rf /etc/forticlient/config.xml
fi
if [ -f /etc/forticlient/config_backup.xml ]; then
- rm -rf /etc/forticlient/config_backup.xml
+ rm -rf /etc/forticlient/config_backup.xml
fi
# Remove old pid lock
if [ -f /tmp/.forticlient/fortivpn.pid ]; then
- rm -rf /tmp/.forticlient/fortivpn.pid
+ rm -rf /tmp/.forticlient/fortivpn.pid
+ fi
+
+ if [ -f /opt/forticlient/Fortitray.desktop ]; then
+ ln -sf /opt/forticlient/Fortitray.desktop /etc/xdg/autostart/Fortitray.desktop
+ fi
+
+ if [ -f /opt/forticlient/Fortivpn.desktop ]; then
+ ln -sf /opt/forticlient/Fortivpn.desktop /etc/xdg/autostart/Fortivpn.desktop
+ fi
+
+ # Restore permissions to all files
+ if [ -f /opt/forticlient/.repackaged ] && [ -f /opt/forticlient/.acl ]; then
+ (
+ cd /
+ setfacl --restore /opt/forticlient/.acl
+ )
fi
if [ -f /etc/forticlient/servers.conf ]; then
- chmod 600 /etc/forticlient/servers.conf
+ chmod 600 /etc/forticlient/servers.conf
fi
# Create GUI symlink to launch from terminal
if [ -f /opt/forticlient/gui/FortiClient-linux-x64/FortiClient ]; then
- ln -sf /opt/forticlient/gui/FortiClient-linux-x64/FortiClient /usr/bin/forticlient
+ ln -sf /opt/forticlient/gui/FortiClient-linux-x64/FortiClient /usr/bin/forticlient
fi
# Launch fortitray
if [ -f /opt/forticlient/fortitraylauncher ]; then
- if [ ! -z "$(logname 2>/dev/null)" ]; then
- user="$(logname 2>/dev/null)"
- elif [ ! -z "$SUDO_USER" ]; then
- user="$SUDO_USER"
- else
- user=$(users 2>/dev/null | cut -d ' ' -f1)
- fi
-
- # Need to find the user DBUS address, otherwise Fortitray icon won't show
- DBUS_SESSION_BUS_ADDRESS=$(ps -u $(id -u $user) -o pid= | xargs -I{} cat /proc/{}/environ 2>/dev/null | tr '\0' '\n' 2>/dev/null | grep -m1 '^DBUS_SESSION_BUS_ADDRESS=')
- DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS#*=}
-
- # XAUTHORITY and DISPLAY needed by Fortitray to run
- XAUTHORITY=$(ps -u $(id -u $user) -o pid= | xargs -I{} cat /proc/{}/environ 2>/dev/null | tr '\0' '\n' 2>/dev/null | grep -m1 '^XAUTHORITY=')
- XAUTHORITY=${XAUTHORITY#*=}
-
- DISPLAY=$(ps -u $(id -u $user) -o pid= | xargs -I{} cat /proc/{}/environ 2>/dev/null | tr '\0' '\n' 2>/dev/null | grep -m1 '^DISPLAY=')
- DISPLAY=${DISPLAY#*=}
-
- XDG_RUNTIME_DIR=$(ps -u $(id -u $user) -o pid= | xargs -I{} cat /proc/{}/environ 2>/dev/null | tr '\0' '\n' 2>/dev/null | grep -m1 '^XDG_RUNTIME_DIR=')
- XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR#*=}
-
- # Start fortitraylauncher while forwarding environment variables needed by Fortitray
- su ${user} -c "env XAUTHORITY=$XAUTHORITY \
- DISPLAY=$DISPLAY \
- DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS \
- XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
- setsid /opt/forticlient/fortitraylauncher &>/dev/null &"
- fi
-
+ if [ ! -z "$(logname 2>/dev/null)" ]; then
+ user="$(logname 2>/dev/null)"
+ elif [ ! -z "$SUDO_USER" ]; then
+ user="$SUDO_USER"
+ else
+ user=$(users 2>/dev/null | cut -d ' ' -f1)
+ fi
+
+ # Need to find the user DBUS address, otherwise Fortitray icon won't show
+ DBUS_SESSION_BUS_ADDRESS=$(ps -u $(id -u $user) -o pid= | xargs -I{} cat /proc/{}/environ 2>/dev/null | tr '\0' '\n' 2>/dev/null | grep -m1 '^DBUS_SESSION_BUS_ADDRESS=')
+ DBUS_SESSION_BUS_ADDRESS=${DBUS_SESSION_BUS_ADDRESS#*=}
+
+ # XAUTHORITY and DISPLAY needed by Fortitray to run
+ XAUTHORITY=$(ps -u $(id -u $user) -o pid= | xargs -I{} cat /proc/{}/environ 2>/dev/null | tr '\0' '\n' 2>/dev/null | grep -m1 '^XAUTHORITY=')
+ XAUTHORITY=${XAUTHORITY#*=}
+
+ DISPLAY=$(ps -u $(id -u $user) -o pid= | xargs -I{} cat /proc/{}/environ 2>/dev/null | tr '\0' '\n' 2>/dev/null | grep -m1 '^DISPLAY=')
+ DISPLAY=${DISPLAY#*=}
+
+ XDG_RUNTIME_DIR=$(ps -u $(id -u $user) -o pid= | xargs -I{} cat /proc/{}/environ 2>/dev/null | tr '\0' '\n' 2>/dev/null | grep -m1 '^XDG_RUNTIME_DIR=')
+ XDG_RUNTIME_DIR=${XDG_RUNTIME_DIR#*=}
+
+ # Start fortitraylauncher while forwarding environment variables needed by Fortitray
+ su ${user} -c "env XAUTHORITY=$XAUTHORITY \
+ DISPLAY=$DISPLAY \
+ DBUS_SESSION_BUS_ADDRESS=$DBUS_SESSION_BUS_ADDRESS \
+ XDG_RUNTIME_DIR=$XDG_RUNTIME_DIR \
+ setsid /opt/forticlient/fortitraylauncher &>/dev/null &"
+ fi
+
# Update icons cache so icon will show correctly
if [ -f /usr/share/icons/hicolor/48x48/apps/forticlient.png ]; then
- gtk-update-icon-cache -f /usr/share/icons/hicolor || true
+ gtk-update-icon-cache -f /usr/share/icons/hicolor || true
fi
-
+
# Setup forticlient protocol handler
if [ -f /usr/share/applications/forticlient-register.desktop ]; then
- update-desktop-database
+ update-desktop-database
+ fi
+
+ # Stop reload daemons
+ if [ -d /run/systemd/system ]; then
+ systemctl --system daemon-reload > /dev/null || true
fi
}
@@ -116,12 +143,6 @@ EOF
}
pre_remove() {
- # Check if forticlient is registered to EMS if it's an uninstall
- if [ -f /opt/forticlient/.fct_ec_registered ] && [ "$action" != "upgrade" ]; then
- echo "Error: Unable to uninstall forticlient while connected to EMS"
- exit 1
- fi
-
# Stop fortitray
if [ -f /tmp/.forticlient/fortitraylauncher ]; then
echo "terminate" > /tmp/.forticlient/fortitraylauncher || true
@@ -138,14 +159,50 @@ pre_remove() {
done
fi
+ # Stop forticlient service
+ if [ -d /run/systemd/system ]; then
+ systemctl stop forticlient-scheduler.service
+ fi
+
pkill -f /opt/forticlient
exit 0
}
post_remove() {
+ # Stop reload daemons
+ if [ -d /run/systemd/system ]; then
+ systemctl --system daemon-reload > /dev/null || true
+ fi
+
# Remove shared memory
rm -rf /var/run/fctc.s || true
+ # Remove Fortitray.desktop symlink
+ rm -rf /etc/xdg/autostart/Fortitray.desktop || true
+
# Remove fortitraylauncher fifo
rm -rf /tmp/.forticlient/fortitraylauncher || true
+
+ # Remove VPN autostart launcher symlink
+ rm -rf /etc/xdg/autostart/Fortivpn.desktop || true
+
+ # Remove GUI symlink
+ rm -rf /usr/bin/forticlient || true
+
+ # Remove fortivpn symlink
+ rm -rf /usr/bin/forticlient || true
+
+ # Remove FortiClient scheduler
+ rm -rf /lib/systemd/system/forticlient-scheduler.service || true
+
+ # Remove FortiClient binaries
+ rm -rf /opt/forticlient || true
+
+ # Remove fortitray policy
+ rm -rf /usr/share/polkit-1/actions/org.fortinet.fortitray.policy || true
+
+ # Remove forticlient policy
+ rm -rf /usr/share/polkit-1/actions/org.fortinet.forticlient.policy || true
+
+ exit 0
}