i need your support to create a script necessary to deploy, start and stop a service from one server to the others server. This service is a jar with a properties file.
I would create a menu script with more choice.
I've created it like this:
#!/bin/bash
PS3='Please enter your choice: '
options=("Start" "Stop" "Deploy" "Quit")
select opt in "${options[@]}"
do
case $opt in
"Start Shaw")
echo "you chose choice 1"
;;
"Stop Shaw")
echo "you chose choice 2"
;;
"Check Shaw Status")
echo "you chose choice 3"
;;
"Quit")
break
;;
*) echo "invalid option $REPLY";;
esac
done
i don't know how to connect the choices to the various functions.
Start function:
I thought of such a thing:
function start_service ( )
{
ssh $1 'nohup /data/jdk1.8.0_151/bin/java -jar -Xmx1024M /data/apps/file.jar &'
}
echo "Starting servers"
for serv_name in $( cat /data/server_list/list.txt )
do start_service ${serv_name} &
echo $! > pid.file &
sleep 5
done
where list.txt is a file with all the servers where this service need to be start. The problem is that i need that the file pid.file is created on each server and that by launching it from the first server, a process is not created on the first server for each server listed but one process for each server.
Stop:
i need that starting from the pid.file, a command that read the file.pid and stop that process like: kill $(cat pid.file)
Deploy:
this is the very problem. I'd like to create a folder where putting the jar file or the properties file inside it, selecting this function, the file is deployed on all servers in the defined paths: jar file: /pathtofile/apps/file.jar file properties: /pathtofile/conf/file.properties
PS: i can't use systemd for security question i don't have root access to the servers.
