From 55ca93427ce6bc22071ef316deb90731e5a0973a Mon Sep 17 00:00:00 2001 From: Preston Kutzner Date: Thu, 26 Apr 2018 19:59:12 -0500 Subject: [PATCH 1/2] - Remove superfluous sudos - Check for effective UID of 0 and error/exit if false. - Remove setting execute bit on unit file and replace with running 'systemctl daemon-reload' --- xo_install.sh | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/xo_install.sh b/xo_install.sh index 16502f1..28323ad 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -1,5 +1,8 @@ #!/bin/bash +# Check if we were effectively run as root +[ $EUID = 0 ] || { echo "This script needs to be run as root!"; exit 1 } + xo_branch="master" xo_server="https://github.com/vatesfr/xen-orchestra" n_repo="https://raw.githubusercontent.com/visionmedia/n/master/bin/n" @@ -11,22 +14,26 @@ xo_server_dir="/opt/xen-orchestra" systemd_service_dir="/lib/systemd/system" xo_service="xo-server.service" +#Ensure that git and curl are installed +/usr/bin/apt-get update +/usr/bin/apt-get --yes install git curl + #Install node and yarn cd /opt -/usr/bin/curl -sL $node_source | sudo -E bash - -/usr/bin/curl -sS $yarn_gpg | sudo apt-key add - -echo "$yarn_repo" | sudo tee /etc/apt/sources.list.d/yarn.list -sudo /usr/bin/apt-get update -sudo /usr/bin/apt-get install --yes nodejs yarn +/usr/bin/curl -sL $node_source | bash - +/usr/bin/curl -sS $yarn_gpg | apt-key add - +echo "$yarn_repo" | tee /etc/apt/sources.list.d/yarn.list +/usr/bin/apt-get update +/usr/bin/apt-get install --yes nodejs yarn #Install n /usr/bin/curl -o $n_location $n_repo -sudo /bin/chmod +x $n_location -sudo /usr/local/bin/n lts +/bin/chmod +x $n_location +/usr/local/bin/n lts #Install XO dependencies -sudo /usr/bin/apt-get install --yes build-essential redis-server libpng-dev git python-minimal libvhdi-utils nfs-common +/usr/bin/apt-get install --yes build-essential redis-server libpng-dev git python-minimal libvhdi-utils nfs-common /usr/bin/git clone -b $xo_branch $xo_server @@ -38,8 +45,8 @@ cd $xo_server_dir /usr/bin/yarn build cd packages/xo-server -sudo cp sample.config.yaml .xo-server.yaml -sudo sed -i "s|#'/': '/path/to/xo-web/dist/'|'/': '/opt/xen-orchestra/packages/xo-web/dist'|" .xo-server.yaml +cp sample.config.yaml .xo-server.yaml +sed -i "s|#'/': '/path/to/xo-web/dist/'|'/': '/opt/xen-orchestra/packages/xo-web/dist'|" .xo-server.yaml if [[ ! -e $systemd_service_dir/$xo_service ]] ; then @@ -61,9 +68,9 @@ WantedBy=multi-user.target EOF fi -sudo /bin/chmod +x $systemd_service_dir/$xo_service -sudo /bin/systemctl enable $xo_service -sudo /bin/systemctl start $xo_service +/bin/systemctl daemon-reload +/bin/systemctl enable $xo_service +/bin/systemctl start $xo_service echo "" echo "" From b6a5e6c9a93ce88009203d6dc4f35f4f8cacbdbd Mon Sep 17 00:00:00 2001 From: Preston Kutzner Date: Thu, 26 Apr 2018 20:02:51 -0500 Subject: [PATCH 2/2] Fix missing ';' --- xo_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xo_install.sh b/xo_install.sh index 28323ad..f5bdc11 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -1,7 +1,7 @@ #!/bin/bash # Check if we were effectively run as root -[ $EUID = 0 ] || { echo "This script needs to be run as root!"; exit 1 } +[ $EUID = 0 ] || { echo "This script needs to be run as root!"; exit 1; } xo_branch="master" xo_server="https://github.com/vatesfr/xen-orchestra"