Advertisement
Guest User

Untitled

a guest
Apr 2nd, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. R='\033[0;31m'
  4. G='\033[0;32m'
  5. B='\033[0;34m'
  6. NC='\033[0m'
  7. FILE="options.ini"
  8. USER="$(whoami)"
  9. ARCH="$(/bin/uname -m)"
  10. BASEDIR="$(dirname $0)"
  11. PKGSDIR="$BASEDIR/pkgs"
  12. CONFDIR="/opt/cososys/share/apps/epp-client"
  13. SERVICE="epp-client-daemon-d"
  14.  
  15. function installRequirements() {
  16. # Install requirements that needed by EPP Client
  17. sudo add-apt-repository universe -y
  18. sudo apt update
  19. sudo apt install gdebi-core gdebi -y
  20. }
  21.  
  22. function installRelatedPackages() {
  23. # Install related packages
  24. echo -e "${G}Installing CoSoSys related packages for EPP-Client${NC}"
  25. sudo dpkg -i $PKGSDIR/cososys-filesystem_1.0.0-0ubuntu1_all.deb
  26. sudo dpkg -i $PKGSDIR/epp-client-cap-def_1.0.5-0ubuntu1_all.deb
  27. sudo dpkg -i $PKGSDIR/epp-client-config_1.0.2-0ubuntu1_all.deb
  28.  
  29. if [ "$ARCH" == "x86_64" ]; then
  30. echo -e "${G}Installing $ARCH packages...${NC}"
  31. sudo dpkg -i $PKGSDIR/libtinyxml2.6.2v5_2.6.2-3_amd64.deb
  32. else
  33. echo -e "${G}Installing $ARCH packages...${NC}"
  34. sudo dpkg -i $PKGSDIR/libtinyxml2.6.2v5_2.6.2-3_i386.deb
  35. fi
  36. }
  37.  
  38. function createSettings() {
  39. # Append settings to $FILE
  40. echo -e "ws_server=$epp_server\nws_port=$epp_port\nDepartmentCode=$deptcode" | tee $FILE
  41. }
  42.  
  43. function setupConfigs() {
  44. # Setup configs and crontab for eppclient
  45. sudo cp $PKGSDIR/check-eppclient-process.sh /opt/cososys/check-eppclient-process.sh
  46. sudo chmod 755 /opt/cososys/check-eppclient-process.sh
  47. 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 -
  48. }
  49.  
  50. # input epp server informations
  51. while true; do
  52. read -p "Enter EPP Server Address IP : " epp_server
  53. read -p "Enter EPP Server Port Number : " epp_port
  54. read -p "Enter Your Departement Code : " deptcode
  55.  
  56. if [ -z $epp_server ] || [ -z $epp_port ] || [ -z $deptcode ]; then
  57. echo "Please complete the input"
  58. else
  59. read -p "Do you wish to install this program? [Y/n] " yn
  60. case $yn in
  61. [Yy]* ) createSettings; installRequirements; break;;
  62. [Nn]* ) exit;;
  63. * ) echo "Please answer yes or no.";;
  64. esac
  65. fi
  66. done
  67.  
  68. ## Begin installation with prerequisites
  69. echo -e "${G}Begin EPP Client installation${NC}"
  70.  
  71. ## Check if epp-client already installed
  72. EPPINSTALLED="$(sudo dpkg -l | awk '{print $2}'| grep '^epp-client$')"
  73. if [ "$EPPINSTALLED" != '' ]; then
  74. EPPSTATUS="$(sudo dpkg -l | grep 'epp-client' | awk '{print $1}' | head -1)"
  75. if [ "$EPPSTATUS" == "ii" -o "$EPPSTATUS" == "iU" ]; then
  76. echo -e "${G}EPP Client is installed. Updating options.ini...${NC}"
  77. echo "Stopping $SERVICE"
  78. sudo service $SERVICE stop
  79. echo "Changing $CONFDIR/$FILE with content:"
  80. sudo cat $PATH/$FILE
  81. sudo chmod 777 $CONFDIR/$FILE
  82. sudo cat $PATH/$FILE > $CONFDIR/$FILE
  83. echo "Starting $SERVICE"
  84. sudo service $SERVICE start > /dev/null 2>&1 &
  85. if [ $USER != root ]; then
  86. echo
  87. echo -e "${B}Options.ini updated!${NC}"
  88. echo
  89. else
  90. echo
  91. echo -e "${B}To activate the client notifier on logged user${NC}"
  92. echo -e "${B}please run: /opt/cososys/bin/epp-client &${NC}"
  93. echo
  94. fi
  95. exit 1
  96.  
  97. fi
  98. fi
  99.  
  100. installRelatedPackages
  101.  
  102. echo -e "${G}Changing config file to match IP/PORT/Department with provided values${NC}"
  103. cat $PATH/$FILE | sudo tee -a $CONFDIR/$FILE
  104.  
  105. setupConfigs
  106.  
  107. echo -e "${B}##############################################${NC}"
  108. echo -e "${B}# Epp client successfully installed! #${NC}"
  109. echo -e "${B}##############################################${NC}"
  110.  
  111. if [ $USER != root ]; then
  112. /opt/cososys/bin/epp-client > /dev/null 2>&1 &
  113. else
  114. echo -e "${B}To activate the client notifier ${NC}"
  115. echo -e "${B}please go to Dash and search for Endpoint Protector Notifier!${NC}"
  116. echo
  117. fi
  118.  
  119. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement