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

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

Copyt trusty code

File size: 2.0 KB
Line 
1#!/bin/bash
2
3FILES="OCSNG.pkg cacert.pem launchfiles modules.conf scripts"
4EXCLUDE="--exclude=*CVS* --exclude=*.svn/* --exclude=*DS_Store*"
5DEPLOYMENT_DIR="unified_unix_agent-macosx"
6PKG_NAME="unified_unix_agent-macosx"
7
8if [ ! -d ./$DEPLOYMENT_DIR ]; then
9        echo "making deployment directory $DEPLOYMENT_DIR"
10        mkdir $DEPLOYMENT_DIR
11fi
12
13echo "copying the files needed to our working dir: $DEPLOYMENT_DIR"
14for FILE in $FILES; do
15        cp -R $FILE $DEPLOYMENT_DIR
16done
17
18echo "tar'ing the file..."
19tar $EXCLUDE -zcf $PKG_NAME.tar.gz $DEPLOYMENT_DIR
20
21echo "generating the installer_wrapper.sh script"
22# this is where we create the install_wrapper script
23# if you modify, besure to 'escape' (using a '\') any variables
24
25cat > install_wrapper.sh << EOF
26#!/bin/bash
27
28VERSION=`perl scripts/extract_version.pl`
29
30function usage {
31        echo "This program does..."
32        echo "usage: \$0 [-s] [-t]"
33        echo ""
34        echo "  -s      : SERVER address (in the format: 'http://example.com/ocsreports')"
35        echo "  -t      : TAG (defaut: DEFAULT)"
36        echo ""
37        echo "  example: \$0 -s http://inventory.example.com/ocsreports -t NEWYORK"
38        echo ""
39}
40
41SERVER="ocsinventory"
42TAG="DEFAULT"
43LOGFILE="/var/log/ocsng.log"
44TMPDIR="/tmp"
45
46while getopts ":s:t:hl:d:T:" Option
47do
48        case \$Option in
49                s) SERVER=\$OPTARG;;
50                t) TAG=\$OPTARG;;
51                l) LOGFILE=\$OPTARG;;
52                T) TMPDIR=\$OPTARG;;
53                h) usage; exit;
54        esac
55done
56
57dir=\`dirname \$0\`;
58if [ x\$dir = "x." ]
59then
60        dir=\`pwd\`
61fi
62base=\`basename \$0\`;
63
64(cd \$TMPDIR; uudecode -p \$dir/\$base|tar xzfv -)
65cd \$TMPDIR/$DEPLOYMENT_DIR;
66echo "logfile=\$LOGFILE" >> ocsinventory-agent.cfg
67echo "server=\$SERVER" >> ocsinventory-agent.cfg
68echo "tag=\$TAG" >> ocsinventory-agent.cfg
69sh scripts/installer.sh
70exit 0;
71EOF
72
73# end of generated script for installer_wrapper.sh
74
75echo "Appending $PKG_NAME.tar.gz to the install_wrapper.sh"
76uuencode $PKG_NAME.tar.gz $PKG_NAME.tar.gz >> install_wrapper.sh
77
78echo "Cleaning up..."
79rm -R -f $DEPLOYMENT_DIR
80rm $PKG_NAME.tar.gz
81echo "Done, you may now use the installer_wrapper.sh to deploy the agent"
Note: See TracBrowser for help on using the repository browser.