fork download
  1. #!/bin/bash
  2. # $Id$
  3. INSTOPT=$1
  4. KEY=$2
  5. infoMessage(){
  6. echo "Usage: $0 [ install | update | start | stop | remove ]
  7. Installation of Linux Agent
  8.  
  9. All these operations can be performed only by the root user.
  10.  
  11. To install the agent as a service for the resource:
  12. * For password management, self-service privilege elevation and zero trust implementation,
  13. execute the command - sh installAgent-service.sh / bash installAgent-service.bash install <Agent Key copied from the PAM360 UI> 1,2,3
  14. * For password management
  15. execute the command - sh installAgent-service.sh / bash installAgent-service.bash install <Agent Key copied from the PAM360 UI> 1
  16. * For self-service privilege elevation
  17. execute the command - sh installAgent-service.sh / bash installAgent-service.bash install <Agent Key copied from the PAM360 UI> 2
  18. * For Zero Trust implementation
  19. execute the command - sh installAgent-service.sh / bash installAgent-service.bash install <Agent Key copied from the PAM360 UI> 3
  20.  
  21. To install the agent as a service for the user device
  22. execute the command - installAgent-service.sh install <key> userdevice <PAM360 username>
  23.  
  24. To update the agent as a service for the resource:
  25. * For password management, self-service privilege elevation and zero trust implementation,
  26. execute the command - sh installAgent-service.sh / bash installAgent-service.bash update <Agent Key copied from the PAM360 UI> 1,2,3
  27. * For password management
  28. execute the command - sh installAgent-service.sh / bash installAgent-service.bash update <Agent Key copied from the PAM360 UI> 1
  29. * For self-service privilege elevation
  30. execute the command - sh installAgent-service.sh / bash installAgent-service.bash update <Agent Key copied from the PAM360 UI> 2
  31. * For Zero Trust implementation
  32. execute the command - sh installAgent-service.sh / bash installAgent-service.bash update <Agent Key copied from the PAM360 UI> 3
  33.  
  34. To update the agent as a service for the user device
  35. execute the command - installAgent-service.sh update <key> userdevice <PAM360 username>
  36.  
  37. To start the agent,
  38. * Execute the command - sh installAgent-service.sh / bash installAgent-service.bash start
  39.  
  40. To stop the agent,
  41. * Execute the command - sh installAgent-service.sh / bash installAgent-service.bash stop
  42.  
  43. To uninstall the agent as service,
  44. * Execute the command - sh installAgent-service.sh / bash installAgent-service.bash remove, to remove PAM360 Agent as service"
  45.  
  46. }
  47.  
  48. if [ "$INSTOPT" == "--help" ] || [ -z "$INSTOPT" ]
  49. then
  50. infoMessage
  51. exit
  52. fi
  53.  
  54. helpInstallationMode(){
  55. infoMessage
  56. }
  57.  
  58. INIT_DIR=/etc/init.d
  59. rootuser="false"
  60. APP_NAME="pam360agent-bash-service"
  61. Zero_Agent="0Agent"
  62. Osqueryd="osqueryd"
  63.  
  64. uid=`id -u`
  65. if [ ${uid} = 0 ]
  66. then
  67. rootuser="true"
  68. else
  69. rootuser="false"
  70. fi
  71.  
  72. if [ "${rootuser}" == "false" ]
  73. then
  74. echo " "
  75. echo "Operation can be performed only by the root user"
  76. echo " "
  77. exit 1
  78. fi
  79.  
  80. doinstall()
  81. {
  82. dir=`pwd`
  83.  
  84. if [ -f $INIT_DIR/$APP_NAME ]
  85. then
  86. echo "PAM360 Agent Service already installed !"
  87. else
  88. cd /etc/init.d
  89. ln -sf $dir/$APP_NAME $INIT_DIR/$APP_NAME
  90. chmod a+x $INIT_DIR/$APP_NAME
  91. chmod a+x $dir/$APP_NAME
  92. ln -sf $INIT_DIR/$APP_NAME /etc/rc2.d/S20$APP_NAME
  93. ln -sf $INIT_DIR/$APP_NAME /etc/rc3.d/S20$APP_NAME
  94. ln -sf $INIT_DIR/$APP_NAME /etc/rc4.d/S20$APP_NAME
  95. ln -sf $INIT_DIR/$APP_NAME /etc/rc5.d/S20$APP_NAME
  96.  
  97. ln -sf $INIT_DIR/$APP_NAME /etc/rc0.d/K20$APP_NAME
  98. ln -sf $INIT_DIR/$APP_NAME /etc/rc1.d/K20$APP_NAME
  99. ln -sf $INIT_DIR/$APP_NAME /etc/rc6.d/K20$APP_NAME
  100.  
  101. echo "PAM360 Agent Service installed successfully !"
  102. cd - >>/dev/null
  103. fi
  104. }
  105.  
  106. function ssperemove(){
  107. usrInfo=$(awk -F: '$3 < 65000 && $3 >= 500 || $3==0 {print $6}' /etc/passwd)
  108. curUser=$(who am i | awk '{print $1}')
  109. filePamPrivilege="/usr/bin/pamprivilegechange"
  110. if [ -f "$filePamPrivilege" ] ; then
  111. echo "Removing pamprivilegechange..."
  112. rm -f /usr/bin/pamprivilegechange
  113. fi
  114.  
  115. echo "Removing pamelevate ..."
  116. IFS=$'\n' #Use newline as delimiter for for-loop
  117. for usrLine in $usrInfo
  118. do
  119. str=$usrLine
  120. permPath="$str/PAM360Elevation/pamelevate"
  121. if [ -f "$permPath" ] ; then
  122. pamelevationPath="$str/PAM360Elevation"
  123. rm -rf "$pamelevationPath"
  124. fi
  125. done
  126.  
  127. }
  128.  
  129. function douninstall()
  130. {
  131. dir=`pwd`
  132.  
  133. cp /etc/profile $dir/profile.bkup.ui
  134. cat $dir/profile.bkup.ui | grep -v MonitorActivities > /etc/profile
  135. rm -rf /var/session/bin
  136.  
  137.  
  138. if [ -f $INIT_DIR/$APP_NAME ]
  139. then
  140. rm -f $INIT_DIR/$APP_NAME
  141. rm -f /etc/rc2.d/S20$APP_NAME
  142. rm -f /etc/rc3.d/S20$APP_NAME
  143. rm -f /etc/rc4.d/S20$APP_NAME
  144. rm -f /etc/rc5.d/S20$APP_NAME
  145.  
  146. rm -f /etc/rc0.d/K20$APP_NAME
  147. rm -f /etc/rc1.d/K20$APP_NAME
  148. rm -f /etc/rc6.d/K20$APP_NAME
  149. ssperemove
  150.  
  151.  
  152. echo "PAM360 Agent Service uninstalled successfully !"
  153. else
  154. ssperemove
  155. echo "PAM360 Agent Service not installed currently"
  156. fi
  157. }
  158. function startpam360() {
  159. if [ -f /etc/init.d/pam360agent-bash-service ]
  160. then
  161. /etc/init.d/pam360agent-bash-service start
  162. else
  163. echo "PAM360 Agent not yet installed. Install agent and try again."
  164. fi
  165. }
  166.  
  167. installpam360()
  168. {
  169. if [ -f /etc/init.d/pam360agent-bash-service ]
  170. then
  171. /etc/init.d/pam360agent-bash-service install $1 $2 $3
  172. else
  173. echo "PAM360 Agent not yet installed. Install agent and try again."
  174. fi
  175.  
  176. }
  177.  
  178. reinstallpam360()
  179. {
  180. if [ -f /etc/init.d/pam360agent-bash-service ]
  181. then
  182. /etc/init.d/pam360agent-bash-service reinstall $1 $2 $3
  183. else
  184. echo "PAM360 Agent not yet installed. Install agent and try again."
  185. fi
  186.  
  187. }
  188.  
  189.  
  190. stoppam360() {
  191. echo -n "Stopping pam360 Agent .... "
  192. pid=`ps -C PAM360Agent -o pid | grep -v PID 2>/dev/null`
  193. if [ "x$pid" != "x" ]; then
  194. kill -9 $pid 2>/dev/null
  195. echo "stopped!"
  196. else
  197. echo "already stopped!"
  198. fi
  199. }
  200. goinstall()
  201. {
  202. stoppam360
  203. douninstall
  204. doinstall
  205. installpam360 $1 $2 $3
  206. startpam360
  207. }
  208. goreinstall()
  209. {
  210. stoppam360
  211. douninstall
  212. doinstall
  213. reinstallpam360 $1 $2 $3
  214. startpam360
  215. }
  216.  
  217.  
  218. if [ "${INSTOPT}" == "remove" ]
  219. then
  220. chmod a+x PAM360Agent
  221. chmod a+x pam360agent-bash-service
  222. chmod a+x ./sspecopy.bash
  223. stoppam360
  224. douninstall
  225. fi
  226.  
  227. if [ "${INSTOPT}" == "install" ]
  228. then
  229. chmod a+x PAM360Agent
  230. chmod a+x pam360agent-bash-service
  231. if [ -f "$Zero_Agent" ] ; then
  232. chmod a+x 0Agent
  233. fi
  234. if [ -f "$Osqueryd" ] ; then
  235. chmod a+x osqueryd
  236. fi
  237. chmod a+x ./sspecopy.bash
  238.  
  239. if [ -z "$2" ]
  240. then
  241. echo "Installation Key Required"
  242. elif [ -z "$3" ]
  243. then
  244. echo "Installation Mode Type Required"
  245. helpInstallationMode
  246. else
  247. if [ "$3" == "userdevice" ]
  248. then
  249. if [ -z "$4" ]
  250. then
  251. echo "Installation user name Required"
  252. else
  253. echo $4
  254. goinstall $2 $3 $4
  255. fi
  256. elif [ "$3" == "1" ] || [ "$3" == "2" ] || [ "$3" == "3" ] || [ "$3" == "1,2" ] || [ "$3" == "2,3" ] || [ "$3" == "1,3" ] || [ "$3" == "1,2,3" ]
  257. then
  258. goinstall $2 $3 $4
  259. else
  260. echo "Installation Mode not valid"
  261. helpInstallationMode
  262. fi
  263. fi
  264. fi
  265.  
  266. if [ "${INSTOPT}" == "start" ]
  267. then
  268. chmod a+x PAM360Agent
  269. chmod a+x pam360agent-bash-service
  270. chmod a+x ./sspecopy.bash
  271. if [ -f "$Zero_Agent" ] ; then
  272. chmod a+x 0Agent
  273. fi
  274. if [ -f "$Osqueryd" ] ; then
  275. chmod a+x osqueryd
  276. fi
  277. startpam360
  278. fi
  279.  
  280. if [ "${INSTOPT}" == "stop" ]
  281. then
  282. chmod a+x PAM360Agent
  283. chmod a+x pam360agent-bash-service
  284. chmod a+x ./sspecopy.bash
  285. if [ -f "$Zero_Agent" ] ; then
  286. chmod a+x 0Agent
  287. fi
  288. if [ -f "$Osqueryd" ] ; then
  289. chmod a+x osqueryd
  290. fi
  291. stoppam360
  292. fi
  293.  
  294. if [ "${INSTOPT}" == "update" ]
  295. then
  296. chmod a+x PAM360Agent
  297. chmod a+x pam360agent-bash-service
  298. chmod a+x ./sspecopy.bash
  299. if [ -f "$Zero_Agent" ] ; then
  300. chmod a+x 0Agent
  301. fi
  302. if [ -f "$Osqueryd" ] ; then
  303. chmod a+x osqueryd
  304. fi
  305. if [ -z "$2" ]
  306. then
  307. echo "Installation Key Required"
  308. elif [ -z "$3" ]
  309. then
  310. echo "Installation Mode Type Required"
  311. helpInstallationMode
  312. else
  313. if [ "$3" == "userdevice" ]
  314. then
  315. if [ -z "$4" ]
  316. then
  317. echo "Installation user name Required"
  318. helpInstallationMode
  319. else
  320. echo $4
  321. goreinstall $2 $3 $4
  322. fi
  323. elif [ "$3" == "1" ] || [ "$3" == "2" ] || [ "$3" == "3" ] || [ "$3" == "1,2" ] || [ "$3" == "2,3" ] || [ "$3" == "1,3" ] || [ "$3" == "1,2,3" ]
  324. then
  325. goreinstall $2 $3 $4
  326. else
  327. echo "Installation Mode not valid"
  328. helpInstallationMode
  329. fi
  330. fi
  331. fi
  332.  
  333.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Usage: ./prog.sh [ install | update | start | stop | remove ]
  Installation of Linux Agent

  All these operations can be performed only by the root user.

  To install the agent as a service for the resource:
  * For password management, self-service privilege elevation and zero trust implementation,
    execute the command - sh installAgent-service.sh / bash installAgent-service.bash install <Agent Key copied from the PAM360 UI> 1,2,3
  * For password management
    execute the command - sh installAgent-service.sh / bash installAgent-service.bash install <Agent Key copied from the PAM360 UI> 1
  * For self-service privilege elevation
    execute the command - sh installAgent-service.sh / bash installAgent-service.bash install <Agent Key copied from the PAM360 UI> 2
  * For Zero Trust implementation
    execute the command - sh installAgent-service.sh / bash installAgent-service.bash install <Agent Key copied from the PAM360 UI> 3

  To install the agent as a service for the user device
   execute the command - installAgent-service.sh install <key> userdevice <PAM360 username>

   To update the agent as a service for the resource:
  * For password management, self-service privilege elevation and zero trust implementation,
    execute the command - sh installAgent-service.sh / bash installAgent-service.bash update <Agent Key copied from the PAM360 UI> 1,2,3
  * For password management
    execute the command - sh installAgent-service.sh / bash installAgent-service.bash update <Agent Key copied from the PAM360 UI> 1
  * For self-service privilege elevation
    execute the command - sh installAgent-service.sh / bash installAgent-service.bash update <Agent Key copied from the PAM360 UI> 2
  * For Zero Trust implementation
    execute the command - sh installAgent-service.sh / bash installAgent-service.bash update <Agent Key copied from the PAM360 UI> 3

To update the agent as a service for the user device
   execute the command - installAgent-service.sh update <key> userdevice <PAM360 username>

  To start the agent,
  *  Execute the command - sh installAgent-service.sh / bash installAgent-service.bash start

  To stop the agent,
  *  Execute the command - sh installAgent-service.sh / bash installAgent-service.bash stop

  To uninstall the agent as service,
  *  Execute the command - sh installAgent-service.sh / bash installAgent-service.bash remove, to remove PAM360 Agent as service