"Fossies" - the Fresh Open Source Software Archive

Member "unix/Darwin/dmg/scripts/postinstall" (15 Sep 2021, 3542 Bytes) of package /linux/misc/pandorafms_agent_unix-7.0NG.757.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #!/usr/bin/env bash
    2 cd /usr/local/share/pandora_agent/
    3 
    4 # Copy daemon file
    5 mv com.pandorafms.pandorafms.plist /Library/LaunchDaemons/
    6 
    7 if [ -f /etc/pandora/pandora_agent.conf ]
    8 then
    9     # Stop the agent process
   10     `launchctl stop com.pandorafms.pandorafms`
   11     PFMSAGENT=`ps aux | grep pandora_agent | grep -v postinstall | grep -v grep | wc -l`
   12     if [ "$PFMSAGENT" -gt "0" ]
   13     then
   14             PIDAGENT=`ps aux | grep pandora_agent | grep -v postinstall | grep -v grep | awk '{print $2}'`
   15             kill $PIDAGENT
   16     fi
   17 else
   18     # Ask for user and password
   19     SERVER=`/usr/local/share/pandora_agent/inst_utilities/get_serverip.scpt`
   20     GROUP=`/usr/local/share/pandora_agent/inst_utilities/get_group.scpt`
   21     REMOTECFG=`/usr/local/share/pandora_agent/inst_utilities/get_remotecfg.scpt`
   22 
   23     # Write the conf file
   24     `/usr/local/share/pandora_agent/inst_utilities/print_conf.pl /usr/local/share/pandora_agent/pandora_agent.conf server_ip $SERVER`
   25     `/usr/local/share/pandora_agent/inst_utilities/print_conf.pl /usr/local/share/pandora_agent/pandora_agent.conf group $GROUP`
   26     `/usr/local/share/pandora_agent/inst_utilities/print_conf.pl /usr/local/share/pandora_agent/pandora_agent.conf remote_config $REMOTECFG`
   27     
   28     # Create agent directories and files
   29     mkdir -p /usr/local/bin/
   30     mkdir -p /usr/local/share/man/man1/
   31     mkdir -p /usr/local/share/pandora_agent/collections/
   32     mkdir -p /usr/local/share/pandora_agent/commands/
   33     mkdir -p /etc/pandora/
   34     mkdir -p /var/spool/pandora/data_out/
   35     mkdir -p /var/log/pandora/
   36     mv pandora_agent.conf /etc/pandora/
   37     touch /var/log/pandora/pandora_agent.log
   38 
   39     # Setting permissions to directories and files
   40     chmod -R 700 /usr/local/share/pandora_agent/collections
   41     chmod -R 700 /usr/local/share/pandora_agent/commands
   42     chmod -R 755 /etc/pandora/
   43     chmod -R 700 /var/spool/pandora/data_out
   44     chmod -R 711 /var/log/pandora
   45     chmod 640 /var/log/pandora/pandora_agent.log
   46     chmod 640 /etc/pandora/pandora_agent.conf
   47 fi
   48 
   49 # Copying agent utilities to /usr/local/bin and securing them
   50 cp -f pandora_agent /usr/local/bin/
   51 chmod 755 /usr/local/bin/pandora_agent
   52 chown root:wheel /usr/local/bin/pandora_agent
   53 
   54 cp -f pandora_agent_exec /usr/local/bin/
   55 chmod 755 /usr/local/bin/pandora_agent_exec
   56 chown root:wheel /usr/local/bin/pandora_agent_exec
   57 
   58 cp -f pandora_revent /usr/local/bin/
   59 chmod 755 /usr/local/bin/pandora_revent
   60 chown root:wheel /usr/local/bin/pandora_revent
   61 
   62 # Copying tentacle_client to /usr/local/bin and securing it
   63 cp -f tentacle_client /usr/local/bin/
   64 chmod 755 /usr/local/bin/tentacle_client
   65 chown root:wheel /usr/local/bin/tentacle_client
   66 
   67 
   68 # Create symbolic links in /etc/pandora/
   69 ln -s /usr/local/share/pandora_agent/plugins /etc/pandora/plugins
   70 ln -s /usr/local/share/pandora_agent/commands /etc/pandora/commands
   71 ln -s /usr/local/share/pandora_agent/collections /etc/pandora/collections
   72 
   73 
   74 # Copy manuals
   75 cp -f man/man1/pandora_agent.1.gz /usr/local/share/man/man1/
   76 chmod 644 /usr/local/share/man/man1/pandora_agent.1.gz
   77 cp -f man/man1/tentacle_client.1.gz /usr/local/share/man/man1/
   78 chmod 644 /usr/local/share/man/man1/tentacle_client.1.gz
   79 
   80 # Create newsyslog entry
   81 #       logfilename                 [owner:group]      mode     count    size(KB)     when      flags  [/pid_file]  [sig_num]
   82 echo "/var/log/pandora/pandora_agent.log        :        640        5        2048        *        Z" > /etc/newsyslog.d/pandora_agent.conf
   83 
   84 # Install the daemon
   85 `launchctl load -wF /Library/LaunchDaemons/com.pandorafms.pandorafms.plist`
   86 
   87 # Launch the daemon
   88 `launchctl start com.pandorafms.pandorafms`
   89 
   90 # Clean all install utilites
   91 rm -Rf inst_utilities
   92 
   93 exit 0