Debian Codegraph @

macosx/ocsinventory_packages_setup/scripts/postinstall

raw
1 #!/bin/bash
2
3 #Setting temp directory
4 if [ $3 ] #If run from NetInstall
5 then
6 TMP_DIR=$3/tmp/ocs_installer
7 else
8 TMP_DIR=/tmp/ocs_installer
9 fi
10
11 INSTALL_PATH="/Applications/OCSNG.app"
12
13 #We set rights to install directory
14 chown -R root:wheel $INSTALL_PATH
15 chmod -R 755 $INSTALL_PATH
16
17 #We set rights to ocscontact binary
18 chown root:wheel $INSTALL_PATH/Contents/Resources/ocscontact
19 chmod 700 $INSTALL_PATH/Contents/Resources/ocscontact
20
21 #We set rights to uninstall script in install path
22 chmod 700 $INSTALL_PATH/Contents/Resources/uninstaller.sh
23
24 #We set etc configuration path
25 ETCPATH="/etc/ocsinventory-agent"
26 mkdir $ETCPATH/
27 cp $TMP_DIR/ocsinventory-agent.cfg $ETCPATH/
28 cp $TMP_DIR/modules.conf $ETCPATH/
29
30 #We set var directory
31 VARPATH="/var/lib/ocsinventory-agent"
32 mkdir -p $VARPATH
33 chown -R root:wheel $VARPATH
34
35 if [ -e $TMP_DIR/serverdir ] && [ -e $TMP_DIR/cacert.pem ]; then
36 SERVERDIR=`cat $TMP_DIR/serverdir`
37 mkdir $SERVERDIR
38 cp $TMP_DIR/cacert.pem $SERVERDIR/
39 fi
40
41 #We set LaunchDaemons plist files
42 LAUNCHDPATH="/Library/LaunchDaemons/"
43 cp $TMP_DIR/org.ocsng.agent.plist $LAUNCHDPATH
44 chown root:wheel $LAUNCHDPATH/org.ocsng.agent.plist
45 chmod 644 $LAUNCHDPATH/org.ocsng.agent.plist
46
47 if [ -f $TMP_DIR/now ]; then
48 echo 'Loading Service'
49 launchctl load $LAUNCHDPATH/org.ocsng.agent.plist
50
51 echo 'Starting Service'
52 launchctl start org.ocsng.agent
53 fi
54
55 #We remove temporary directory
56 rm -Rf $TMP_DIR
57
58 exit 0