source: ocsinventory-agent/trunk/fuentes/tools/macosx/scripts/installer.sh @ 468

Last change on this file since 468 was 468, checked in by mabarracus, 4 years ago

Copyt trusty code

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1#!/bin/bash
2
3
4PREFIX=/tmp/ocs_installer
5
6if [ "$1" == "-custom" ]; then
7        CUSTOM=1
8        PREFIX=./
9fi
10
11INSTALL_PATH="/Applications/OCSNG.app"
12
13echo "Setting rights to $INSTALL_PATH"
14sudo chown -R root:wheel $INSTALL_PATH
15sudo chmod -R 755 $INSTALL_PATH
16
17echo "Setting rights to $INSTALL_PATH/Contents/Resources/ocscontact"
18sudo chown root:wheel $INSTALL_PATH/Contents/Resources/ocscontact
19sudo chmod 700 $INSTALL_PATH/Contents/Resources/ocscontact
20
21echo "Copying uninstall script to $INSTALL_PATH"
22sudo cp $PREFIX/scripts/uninstaller.sh $INSTALL_PATH/Contents/Resources/
23sudo chmod 700 $INSTALL_PATH/Contents/Resources/uninstaller.sh
24
25ETCPATH="/etc/ocsinventory-agent"
26sudo mkdir $ETCPATH/
27sudo cp $PREFIX/ocsinventory-agent.cfg $ETCPATH/
28sudo cp $PREFIX/modules.conf $ETCPATH/
29
30VARPATH="/var/lib/ocsinventory-agent"
31sudo mkdir -p $VARPATH
32sudo chown -R root:wheel $VARPATH
33
34if [ "$CUSTOM" == 1 ]; then
35        if [ -e $PREFIX/cacert.pem ]; then
36                echo "copying cacert.pem to $VARPATH/"
37                sudo cp $PREFIX/cacert.pem $VARPATH/
38        fi
39else
40        if [ -e $PREFIX/serverdir ] && [ -e $PREFIX/cacert.pem ]; then
41                SERVERDIR=`cat $PREFIX/serverdir` 
42                mkdir $SERVERDIR
43                cp $PREFIX/cacert.pem $SERVERDIR/
44        fi
45fi
46
47echo "Setting LaunchDaemons plists"
48LAUNCHDPATH="/Library/LaunchDaemons/"
49
50if [ "$CUSTOM" == 1 ]; then
51        sudo cp $PREFIX/launchfiles/org.ocsng.agent.plist $LAUNCHDPATH
52else
53        sudo cp $PREFIX/org.ocsng.agent.plist $LAUNCHDPATH
54fi
55
56sudo chown root:wheel $LAUNCHDPATH/org.ocsng.agent.plist
57sudo chmod 644 $LAUNCHDPATH/org.ocsng.agent.plist
58
59if [[ -f $PREFIX/now || $CUSTOM -eq 1 ]]; then
60        echo 'Loading Service'
61        sudo launchctl load $LAUNCHDPATH/org.ocsng.agent.plist
62
63        echo 'Starting Service'
64        sudo launchctl start org.ocsng.agent
65fi
66
67if [ ! "$CUSTOM" == 1 ]; then
68        echo 'Removing temporary directory'
69        rm -Rf $PREFIX
70fi
71
72echo 'done'
73exit 0 
Note: See TracBrowser for help on using the repository browser.