more Linux install script fixes.
This commit is contained in:
parent
67eb89143d
commit
9319e6ed43
|
@ -30,58 +30,53 @@ stop() {
|
|||
echo 'Service not running' >&2
|
||||
return 1
|
||||
else
|
||||
pid=$( cat "$PIDFILE" )
|
||||
if kill -0 $pid 2>/dev/null; then
|
||||
pid=$( cat "$PIDFILE" )
|
||||
if kill -0 $pid 2>/dev/null; then
|
||||
echo 'Stopping service…' >&2
|
||||
kill -16 $pid
|
||||
echo 'Service stopped' >&2
|
||||
else
|
||||
echo 'Service not running'
|
||||
fi
|
||||
rm -f $"PIDFILE"
|
||||
else
|
||||
echo 'Service not running'
|
||||
fi
|
||||
rm -f $"PIDFILE"
|
||||
fi
|
||||
}
|
||||
restart(){
|
||||
stop
|
||||
start
|
||||
stop
|
||||
start
|
||||
}
|
||||
status(){
|
||||
if [ -f "$PIDFILE" ]
|
||||
then
|
||||
pid=$( cat "$PIDFILE" )
|
||||
if kill -0 $pid 2>/dev/null; then
|
||||
echo "meshagent start/running, process $pid"
|
||||
else
|
||||
echo 'meshagent stop/waiting'
|
||||
fi
|
||||
else
|
||||
echo 'meshagent stop/waiting'
|
||||
fi
|
||||
if [ -f "$PIDFILE" ]
|
||||
then
|
||||
pid=$( cat "$PIDFILE" )
|
||||
if kill -0 $pid 2>/dev/null; then
|
||||
echo "meshagent start/running, process $pid"
|
||||
else
|
||||
echo 'meshagent stop/waiting'
|
||||
fi
|
||||
else
|
||||
echo 'meshagent stop/waiting'
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: service meshagent {start|stop|restart|status}"
|
||||
;;
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: service meshagent {start|stop|restart|status}"
|
||||
;;
|
||||
esac
|
||||
exit 0
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
CheckStartupType() {
|
||||
# echo "Checking process autostart system..."
|
||||
starttype=`ps -p 1 | awk '/1/ {print $4}'`
|
||||
# 1 is Systemd;
|
||||
# Systemd
|
||||
if [[ $starttype == 'systemd' ]]; then return 1;
|
||||
elif [[ $starttype == 'init' ]];
|
||||
then
|
||||
# 2 is Upstart
|
||||
# Upstart
|
||||
if [[ `/sbin/init --version` =~ upstart ]]; then return 2;
|
||||
# 3 is Sysv-init
|
||||
# Sysv-init
|
||||
return 3;
|
||||
fi
|
||||
fi
|
||||
|
@ -47,8 +47,8 @@ CheckInstallAgent() {
|
|||
if [ $# -ge 3 ]
|
||||
then
|
||||
# echo "Computer type is specified..."
|
||||
machineid=$3
|
||||
else
|
||||
machineid=$3
|
||||
else
|
||||
# echo "Detecting computer type..."
|
||||
if [ $machinetype == 'x86_64' ] || [ $machinetype == 'amd64' ]
|
||||
then
|
||||
|
@ -66,9 +66,9 @@ CheckInstallAgent() {
|
|||
machineid=25
|
||||
fi
|
||||
# Add more machine types, detect KVM support... here.
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $machineid -eq 0 ]
|
||||
if [ $machineid -eq 0 ]
|
||||
then
|
||||
echo "Unsupported machine type: $machinetype."
|
||||
else
|
||||
|
@ -92,13 +92,13 @@ DownloadAgent() {
|
|||
mkdir -p /usr/local/mesh
|
||||
cd /usr/local/mesh
|
||||
echo "Downloading Mesh agent #$machineid..."
|
||||
wget $url/meshagents?id=$machineid --no-check-certificate -O /usr/local/mesh/meshagent
|
||||
wget $url/meshagents?id=$machineid --no-check-certificate {{{noproxy}}}-O /usr/local/mesh/meshagent
|
||||
|
||||
# If it did not work, try again using http
|
||||
if [ $? != 0 ]
|
||||
then
|
||||
url=${url/"https://"/"http://"}
|
||||
wget $url/meshagents?id=$machineid -O /usr/local/mesh/meshagent
|
||||
wget $url/meshagents?id=$machineid {{{noproxy}}}-O /usr/local/mesh/meshagent
|
||||
fi
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
|
@ -106,62 +106,62 @@ DownloadAgent() {
|
|||
echo "Mesh agent downloaded."
|
||||
# TODO: We could check the meshagent sha256 hash, but best to authenticate the server.
|
||||
chmod 755 /usr/local/mesh/meshagent
|
||||
wget $url/meshsettings?id=$meshid --no-check-certificate -O /usr/local/mesh/meshagent.msh
|
||||
wget $url/meshsettings?id=$meshid --no-check-certificate {{{noproxy}}}-O /usr/local/mesh/meshagent.msh
|
||||
|
||||
# If it did not work, try again using http
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
wget $url/meshsettings?id=$meshid -O /usr/local/mesh/meshagent.msh
|
||||
wget $url/meshsettings?id=$meshid {{{noproxy}}}-O /usr/local/mesh/meshagent.msh
|
||||
fi
|
||||
|
||||
if [ $? -eq 0 ]
|
||||
then
|
||||
UpdateMshFile
|
||||
UpdateMshFile
|
||||
if [ $starttype -eq 1 ]
|
||||
then
|
||||
# systemd
|
||||
if [ -d "/lib/systemd/system/" ]
|
||||
then
|
||||
# systemd
|
||||
if [ -d "/lib/systemd/system/" ]
|
||||
then
|
||||
echo -e "[Unit]\nDescription=MeshCentral Agent\n[Service]\nExecStart=/usr/local/mesh/meshagent\nStandardOutput=null\nRestart=always\nRestartSec=3\n[Install]\nWantedBy=multi-user.target\nAlias=meshagent.service\n" > /lib/systemd/system/meshagent.service
|
||||
else
|
||||
# Some distros have the systemd folder at a different place
|
||||
# Some distros have the systemd folder at a different place
|
||||
if [ -d "/usr/lib/systemd/system/" ]
|
||||
then
|
||||
echo -e "[Unit]\nDescription=MeshCentral Agent\n[Service]\nExecStart=/usr/local/mesh/meshagent\nStandardOutput=null\nRestart=always\nRestartSec=3\n[Install]\nWantedBy=multi-user.target\nAlias=meshagent.service\n" > /usr/lib/systemd/system/meshagent.service
|
||||
else
|
||||
echo "Unable to find systemd folder."
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
systemctl enable meshagent
|
||||
systemctl start meshagent
|
||||
echo 'meshagent installed as systemd service.'
|
||||
echo 'To start service: sudo systemctl start meshagent'
|
||||
echo 'To stop service: sudo systemctl stop meshagent'
|
||||
echo 'meshagent installed as systemd service.'
|
||||
echo 'To start service: sudo systemctl start meshagent'
|
||||
echo 'To stop service: sudo systemctl stop meshagent'
|
||||
elif [ $starttype -eq 3 ]
|
||||
then
|
||||
# initd
|
||||
wget $url/meshagents?script=2 --no-check-certificate -O /etc/init.d/meshagent
|
||||
chmod +x /etc/init.d/meshagent
|
||||
# creates symlinks for rc.d
|
||||
update-rc.d meshagent defaults
|
||||
service meshagent start
|
||||
echo 'meshagent installed as init.d service.'
|
||||
echo 'To start service: sudo service meshagent start'
|
||||
echo 'To stop service: sudo service meshagent stop'
|
||||
# initd
|
||||
wget $url/meshagents?script=2 --no-check-certificate {{{noproxy}}}-O /etc/init.d/meshagent
|
||||
chmod +x /etc/init.d/meshagent
|
||||
# creates symlinks for rc.d
|
||||
update-rc.d meshagent defaults
|
||||
service meshagent start
|
||||
echo 'meshagent installed as init.d service.'
|
||||
echo 'To start service: sudo service meshagent start'
|
||||
echo 'To stop service: sudo service meshagent stop'
|
||||
elif [ $starttype -eq 2 ]
|
||||
then
|
||||
# upstart
|
||||
then
|
||||
# upstart
|
||||
echo -e "start on runlevel [2345]\nstop on runlevel [016]\n\nrespawn\n\nchdir /usr/local/mesh\nexec /usr/local/mesh/meshagent\n\n" > /etc/init/meshagent.conf
|
||||
service meshagent start
|
||||
echo 'meshagent installed as upstart/init.d service.'
|
||||
echo 'To start service: sudo service meshagent start'
|
||||
echo 'To stop service: sudo service meshagent stop'
|
||||
else
|
||||
# unknown
|
||||
service meshagent start
|
||||
echo 'meshagent installed as upstart/init.d service.'
|
||||
echo 'To start service: sudo service meshagent start'
|
||||
echo 'To stop service: sudo service meshagent stop'
|
||||
else
|
||||
# unknown
|
||||
echo "Unknown Service Platform Type. (ie: init, systemd, etc)"
|
||||
echo "Unable to install meshagent as service."
|
||||
fi
|
||||
echo "Mesh agent started."
|
||||
echo "Mesh agent started."
|
||||
else
|
||||
echo "Unable to download mesh settings at: $url/meshsettings?id=$meshid."
|
||||
fi
|
||||
|
@ -187,16 +187,17 @@ UninstallAgent() {
|
|||
systemctl stop meshagent
|
||||
else
|
||||
if [ $starttype -eq 3 ]; then
|
||||
# initd
|
||||
service meshagent stop
|
||||
update-rc.d -f meshagent remove
|
||||
rm -f /sbin/meshcmd /etc/init.d/meshagent
|
||||
elif [ $starttype -eq 2 ]; then
|
||||
# upstart
|
||||
service meshagent stop
|
||||
rm -f /sbin/meshcmd
|
||||
rm -f /etc/init/meshagent.conf
|
||||
fi
|
||||
# initd
|
||||
service meshagent stop
|
||||
update-rc.d -f meshagent remove
|
||||
rm -f /sbin/meshcmd /etc/init.d/meshagent
|
||||
elif [ $starttype -eq 2 ]; then
|
||||
# upstart
|
||||
service meshagent stop
|
||||
rm -f /sbin/meshcmd
|
||||
rm -f /etc/init/meshagent.conf
|
||||
rm -f /etc/rc2.d/S20mesh /etc/rc3.d/S20mesh /etc/rc5.d/S20mesh
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -e $installpath ]
|
||||
|
|
|
@ -1275,8 +1275,8 @@ function CreateMeshCentralServer(config, args) {
|
|||
|
||||
// List of possible mesh agent install scripts
|
||||
var meshAgentsInstallScriptList = {
|
||||
1: { id: 1, localname: 'meshinstall-linux.sh', rname: 'meshinstall.sh' },
|
||||
2: { id: 2, localname: 'meshinstall-initd.sh', rname: 'meshagent' }
|
||||
1: { id: 1, localname: 'meshinstall-linux.sh', rname: 'meshinstall.sh', linux: true },
|
||||
2: { id: 2, localname: 'meshinstall-initd.sh', rname: 'meshagent', linux: true }
|
||||
};
|
||||
|
||||
// Update the list of available mesh agents
|
||||
|
@ -1302,6 +1302,9 @@ function CreateMeshCentralServer(config, args) {
|
|||
var stats = null;
|
||||
try { stats = obj.fs.statSync(this.agentpath); } catch (e) { }
|
||||
if (stats != null) { obj.meshAgentInstallScripts[this.info.id].size = stats.size; }
|
||||
|
||||
// Place Unit line breaks on Linux scripts if not already present.
|
||||
if (obj.meshAgentInstallScripts[this.info.id].linux === true) { obj.meshAgentInstallScripts[this.info.id].data = obj.meshAgentInstallScripts[this.info.id].data.split('\r\n').join('\n') }
|
||||
});
|
||||
stream.info = meshAgentsInstallScriptList[scriptid];
|
||||
stream.agentpath = scriptpath;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "meshcentral",
|
||||
"version": "0.2.9-m",
|
||||
"version": "0.2.9-n",
|
||||
"keywords": [
|
||||
"Remote Management",
|
||||
"Intel AMT",
|
||||
|
|
Loading…
Reference in New Issue