mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-03-09 15:40:18 +00:00
more Linux install script fixes.
This commit is contained in:
parent
67eb89143d
commit
9319e6ed43
4 changed files with 90 additions and 91 deletions
|
@ -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 ]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue