Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- R='\033[0;31m'
- G='\033[0;32m'
- B='\033[0;34m'
- NC='\033[0m'
- FILE="options.ini"
- USER="$(whoami)"
- ARCH="$(/bin/uname -m)"
- BASEDIR="$(dirname $0)"
- PKGSDIR="$BASEDIR/pkgs"
- CONFDIR="/opt/cososys/share/apps/epp-client"
- SERVICE="epp-client-daemon-d"
- function installRequirements() {
- # Install requirements that needed by EPP Client
- sudo add-apt-repository universe -y
- sudo apt update
- sudo apt install gdebi-core gdebi -y
- }
- function installRelatedPackages() {
- # Install related packages
- echo -e "${G}Installing CoSoSys related packages for EPP-Client${NC}"
- sudo dpkg -i $PKGSDIR/cososys-filesystem_1.0.0-0ubuntu1_all.deb
- sudo dpkg -i $PKGSDIR/epp-client-cap-def_1.0.5-0ubuntu1_all.deb
- sudo dpkg -i $PKGSDIR/epp-client-config_1.0.2-0ubuntu1_all.deb
- if [ "$ARCH" == "x86_64" ]; then
- echo -e "${G}Installing $ARCH packages...${NC}"
- sudo dpkg -i $PKGSDIR/libtinyxml2.6.2v5_2.6.2-3_amd64.deb
- else
- echo -e "${G}Installing $ARCH packages...${NC}"
- sudo dpkg -i $PKGSDIR/libtinyxml2.6.2v5_2.6.2-3_i386.deb
- fi
- }
- function createSettings() {
- # Append settings to $FILE
- echo -e "ws_server=$epp_server\nws_port=$epp_port\nDepartmentCode=$deptcode" | tee $FILE
- }
- function setupConfigs() {
- # Setup configs and crontab for eppclient
- sudo cp $PKGSDIR/check-eppclient-process.sh /opt/cososys/check-eppclient-process.sh
- sudo chmod 755 /opt/cososys/check-eppclient-process.sh
- sudo /usr/bin/crontab -u root -l; sudo /bin/echo "* * * * * /opt/cososys/check-eppclient-process.sh & > /dev/null 2>&1" | sudo /usr/bin/crontab -u root -
- }
- # input epp server informations
- while true; do
- read -p "Enter EPP Server Address IP : " epp_server
- read -p "Enter EPP Server Port Number : " epp_port
- read -p "Enter Your Departement Code : " deptcode
- if [ -z $epp_server ] || [ -z $epp_port ] || [ -z $deptcode ]; then
- echo "Please complete the input"
- else
- read -p "Do you wish to install this program? [Y/n] " yn
- case $yn in
- [Yy]* ) createSettings; installRequirements; break;;
- [Nn]* ) exit;;
- * ) echo "Please answer yes or no.";;
- esac
- fi
- done
- ## Begin installation with prerequisites
- echo -e "${G}Begin EPP Client installation${NC}"
- ## Check if epp-client already installed
- EPPINSTALLED="$(sudo dpkg -l | awk '{print $2}'| grep '^epp-client$')"
- if [ "$EPPINSTALLED" != '' ]; then
- EPPSTATUS="$(sudo dpkg -l | grep 'epp-client' | awk '{print $1}' | head -1)"
- if [ "$EPPSTATUS" == "ii" -o "$EPPSTATUS" == "iU" ]; then
- echo -e "${G}EPP Client is installed. Updating options.ini...${NC}"
- echo "Stopping $SERVICE"
- sudo service $SERVICE stop
- echo "Changing $CONFDIR/$FILE with content:"
- sudo cat $PATH/$FILE
- sudo chmod 777 $CONFDIR/$FILE
- sudo cat $PATH/$FILE > $CONFDIR/$FILE
- echo "Starting $SERVICE"
- sudo service $SERVICE start > /dev/null 2>&1 &
- if [ $USER != root ]; then
- echo
- echo -e "${B}Options.ini updated!${NC}"
- echo
- else
- echo
- echo -e "${B}To activate the client notifier on logged user${NC}"
- echo -e "${B}please run: /opt/cososys/bin/epp-client &${NC}"
- echo
- fi
- exit 1
- fi
- fi
- installRelatedPackages
- echo -e "${G}Changing config file to match IP/PORT/Department with provided values${NC}"
- cat $PATH/$FILE | sudo tee -a $CONFDIR/$FILE
- setupConfigs
- echo -e "${B}##############################################${NC}"
- echo -e "${B}# Epp client successfully installed! #${NC}"
- echo -e "${B}##############################################${NC}"
- if [ $USER != root ]; then
- /opt/cososys/bin/epp-client > /dev/null 2>&1 &
- else
- echo -e "${B}To activate the client notifier ${NC}"
- echo -e "${B}please go to Dash and search for Endpoint Protector Notifier!${NC}"
- echo
- fi
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement