From 650cab8fe03adabe7b633dd02783058b5578fd5b Mon Sep 17 00:00:00 2001 From: John Hooks Date: Wed, 2 Aug 2017 20:03:53 -0400 Subject: [PATCH 01/13] Add variables for the XO branch and URLs --- xo_install.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/xo_install.sh b/xo_install.sh index 59bafb9..c9c59ce 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -1,4 +1,9 @@ #!/bin/bash + +xo_branch="stable" +xo_server="https://github.com/vatesfr/xo-server" +xo_web="https://github.com/vatesfr/xo-web" + sudo apt-get install --yes nfs-common cd /opt curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash - @@ -10,8 +15,8 @@ curl -o /usr/local/bin/n https://raw.githubusercontent.com/visionmedia/n/master/ sudo chmod +x /usr/local/bin/n sudo n stable sudo apt-get install --yes build-essential redis-server libpng-dev git python-minimal libvhdi-utils -git clone -b stable https://github.com/vatesfr/xo-server -git clone -b stable https://github.com/vatesfr/xo-web +git clone -b $xo_branch $xo_server +git clone -b $xo_branch $xo_web cd xo-server sudo npm install && npm run build sudo cp sample.config.yaml .xo-server.yaml From a51af30a4c83a0fdf76a9e8ec60bb4016b4ee293 Mon Sep 17 00:00:00 2001 From: John Hooks Date: Wed, 2 Aug 2017 20:08:58 -0400 Subject: [PATCH 02/13] Added variables for n, yarn, yarn key, and node --- xo_install.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/xo_install.sh b/xo_install.sh index c9c59ce..70ab099 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -4,14 +4,20 @@ xo_branch="stable" xo_server="https://github.com/vatesfr/xo-server" xo_web="https://github.com/vatesfr/xo-web" +n_repo="https://raw.githubusercontent.com/visionmedia/n/master/bin/n" + +yarn_repo="deb https://dl.yarnpkg.com/debian/ stable main" +node_source="https://deb.nodesource.com/setup_5.x" +yarn_gpg="https://dl.yarnpkg.com/debian/pubkey.gpg" + sudo apt-get install --yes nfs-common cd /opt -curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash - -curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - -echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list +curl -sL $node_source | sudo -E bash - +curl -sS $yarn_gpg | sudo apt-key add - +echo "$yarn_repo" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update sudo apt-get install --yes nodejs yarn -curl -o /usr/local/bin/n https://raw.githubusercontent.com/visionmedia/n/master/bin/n +curl -o /usr/local/bin/n $n_repo sudo chmod +x /usr/local/bin/n sudo n stable sudo apt-get install --yes build-essential redis-server libpng-dev git python-minimal libvhdi-utils From 3dfb424c7f03164954f82d36226adc1d1de466ae Mon Sep 17 00:00:00 2001 From: John Hooks Date: Wed, 2 Aug 2017 20:10:34 -0400 Subject: [PATCH 03/13] Add variable for n location --- xo_install.sh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xo_install.sh b/xo_install.sh index 70ab099..f5fe068 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -10,6 +10,8 @@ yarn_repo="deb https://dl.yarnpkg.com/debian/ stable main" node_source="https://deb.nodesource.com/setup_5.x" yarn_gpg="https://dl.yarnpkg.com/debian/pubkey.gpg" +n_location="/usr/local/bin/n" + sudo apt-get install --yes nfs-common cd /opt curl -sL $node_source | sudo -E bash - @@ -17,8 +19,8 @@ curl -sS $yarn_gpg | sudo apt-key add - echo "$yarn_repo" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt-get update sudo apt-get install --yes nodejs yarn -curl -o /usr/local/bin/n $n_repo -sudo chmod +x /usr/local/bin/n +curl -o $n_location $n_repo +sudo chmod +x $n_location sudo n stable sudo apt-get install --yes build-essential redis-server libpng-dev git python-minimal libvhdi-utils git clone -b $xo_branch $xo_server From 2c704dafcf261d21847f76a3d4b72dc762c9ca8f Mon Sep 17 00:00:00 2001 From: John Hooks Date: Wed, 2 Aug 2017 20:12:10 -0400 Subject: [PATCH 04/13] Add variables for xo-web and xo-server dir and clean up variable spacing. --- xo_install.sh | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/xo_install.sh b/xo_install.sh index f5fe068..fc0e93e 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -3,14 +3,13 @@ xo_branch="stable" xo_server="https://github.com/vatesfr/xo-server" xo_web="https://github.com/vatesfr/xo-web" - n_repo="https://raw.githubusercontent.com/visionmedia/n/master/bin/n" - yarn_repo="deb https://dl.yarnpkg.com/debian/ stable main" node_source="https://deb.nodesource.com/setup_5.x" yarn_gpg="https://dl.yarnpkg.com/debian/pubkey.gpg" - n_location="/usr/local/bin/n" +xo_server_dir="/opt/xo-server" +xo_web_dir="/opt/xo-web" sudo apt-get install --yes nfs-common cd /opt @@ -25,11 +24,11 @@ sudo n stable sudo apt-get install --yes build-essential redis-server libpng-dev git python-minimal libvhdi-utils git clone -b $xo_branch $xo_server git clone -b $xo_branch $xo_web -cd xo-server +cd $xo_server_dir sudo npm install && npm run build sudo cp sample.config.yaml .xo-server.yaml sudo sed -i /mounts/a\\" '/': '/opt/xo-web/dist'" .xo-server.yaml -cd /opt/xo-web +cd $xo_web_dir yarn install --force cat > /etc/systemd/system/xo-server.service < Date: Wed, 2 Aug 2017 21:37:23 -0400 Subject: [PATCH 05/13] Add variables for systemd dir and service Add some comments Add full paths for security Add some spacing --- xo_install.sh | 63 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/xo_install.sh b/xo_install.sh index fc0e93e..eecb6de 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -10,43 +10,54 @@ yarn_gpg="https://dl.yarnpkg.com/debian/pubkey.gpg" n_location="/usr/local/bin/n" xo_server_dir="/opt/xo-server" xo_web_dir="/opt/xo-web" +systemd_service_dir="/lib/systemd/system" +xo_service="xo-server.service" -sudo apt-get install --yes nfs-common +#Install node and yarn cd /opt -curl -sL $node_source | sudo -E bash - -curl -sS $yarn_gpg | sudo apt-key add - +/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 apt-get update -sudo apt-get install --yes nodejs yarn -curl -o $n_location $n_repo -sudo chmod +x $n_location -sudo n stable -sudo apt-get install --yes build-essential redis-server libpng-dev git python-minimal libvhdi-utils -git clone -b $xo_branch $xo_server -git clone -b $xo_branch $xo_web +sudo /usr/bin/apt-get update +sudo /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 stable + +#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/git clone -b $xo_branch $xo_server +/usr/bin/git clone -b $xo_branch $xo_web cd $xo_server_dir sudo npm install && npm run build sudo cp sample.config.yaml .xo-server.yaml sudo sed -i /mounts/a\\" '/': '/opt/xo-web/dist'" .xo-server.yaml cd $xo_web_dir yarn install --force -cat > /etc/systemd/system/xo-server.service <> $xo_systemd_service + # systemd service for XO-Server. -[Install] -WantedBy=multi-user.target + [Unit] + Description= XO Server + After=network-online.target + + [Service] + WorkingDirectory=/opt/xo-server/ + ExecStart=/usr/local/bin/node ./bin/xo-server + Restart=always + SyslogIdentifier=xo-server + + [Install] + WantedBy=multi-user.target EOF +fi -sudo chmod +x /etc/systemd/system/xo-server.service -sudo systemctl enable xo-server.service -sudo systemctl start xo-server.service +sudo /bin/chmod +x $systemd_service_dir/$xo_service +sudo /bin/systemctl enable $xo_service +sudo /bin/systemctl start $xo_service From abedcaf0b96bbd4f5d5675af1c70bffcf8bcfdee Mon Sep 17 00:00:00 2001 From: John Hooks Date: Wed, 2 Aug 2017 21:38:23 -0400 Subject: [PATCH 06/13] Change sed command to replace existing sample mount instead of creating new line. Uses pipe as delimiter so it's easier to read. --- xo_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xo_install.sh b/xo_install.sh index eecb6de..4db767b 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -34,7 +34,7 @@ sudo /usr/bin/apt-get install --yes build-essential redis-server libpng-dev git cd $xo_server_dir sudo npm install && npm run build sudo cp sample.config.yaml .xo-server.yaml -sudo sed -i /mounts/a\\" '/': '/opt/xo-web/dist'" .xo-server.yaml +sudo sed -i "s|#'/': '/path/to/xo-web/dist/'|'/': '/opt/xo-web/dist'|" .xo-server.yaml cd $xo_web_dir yarn install --force From 36cb5935328e54765d4e7bf5110d948ad72618f5 Mon Sep 17 00:00:00 2001 From: John Hooks Date: Wed, 2 Aug 2017 21:39:52 -0400 Subject: [PATCH 07/13] Add full path for npm --- xo_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xo_install.sh b/xo_install.sh index 4db767b..a54261d 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -32,7 +32,7 @@ sudo /usr/bin/apt-get install --yes build-essential redis-server libpng-dev git /usr/bin/git clone -b $xo_branch $xo_server /usr/bin/git clone -b $xo_branch $xo_web cd $xo_server_dir -sudo npm install && npm run build +sudo /usr/bin/npm install && /usr/bin/npm run build sudo cp sample.config.yaml .xo-server.yaml sudo sed -i "s|#'/': '/path/to/xo-web/dist/'|'/': '/opt/xo-web/dist'|" .xo-server.yaml cd $xo_web_dir From aa4650d54f8b3e6cce0e98a82b5eddeaac3775e0 Mon Sep 17 00:00:00 2001 From: John Hooks Date: Wed, 2 Aug 2017 22:05:18 -0400 Subject: [PATCH 08/13] Add full path for yarn --- xo_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xo_install.sh b/xo_install.sh index a54261d..51a8d18 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -36,7 +36,7 @@ sudo /usr/bin/npm install && /usr/bin/npm run build sudo cp sample.config.yaml .xo-server.yaml sudo sed -i "s|#'/': '/path/to/xo-web/dist/'|'/': '/opt/xo-web/dist'|" .xo-server.yaml cd $xo_web_dir -yarn install --force +/usr/bin/yarn install --force if [[ ! -e $xo_systemd_service ]] ; then From 39fcc936290e8da24dbec7ca5447cc0b40c5eabb Mon Sep 17 00:00:00 2001 From: John Hooks Date: Wed, 2 Aug 2017 22:05:56 -0400 Subject: [PATCH 09/13] Remove indents --- xo_install.sh | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/xo_install.sh b/xo_install.sh index 51a8d18..6659aef 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -40,21 +40,21 @@ cd $xo_web_dir if [[ ! -e $xo_systemd_service ]] ; then - /bin/cat << EOF >> $xo_systemd_service - # systemd service for XO-Server. +/bin/cat << EOF >> $xo_systemd_service +# systemd service for XO-Server. - [Unit] - Description= XO Server - After=network-online.target +[Unit] +Description= XO Server +After=network-online.target - [Service] - WorkingDirectory=/opt/xo-server/ - ExecStart=/usr/local/bin/node ./bin/xo-server - Restart=always - SyslogIdentifier=xo-server +[Service] +WorkingDirectory=/opt/xo-server/ +ExecStart=/usr/local/bin/node ./bin/xo-server +Restart=always +SyslogIdentifier=xo-server - [Install] - WantedBy=multi-user.target +[Install] +WantedBy=multi-user.target EOF fi From 7f13ef0e6cfda55c13689edfeb654d0c49a6bbee Mon Sep 17 00:00:00 2001 From: hooksie1 Date: Thu, 3 Aug 2017 10:17:23 -0400 Subject: [PATCH 10/13] Fix incorrect variable for XO service file --- xo_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xo_install.sh b/xo_install.sh index 6659aef..9150479 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -40,7 +40,7 @@ cd $xo_web_dir if [[ ! -e $xo_systemd_service ]] ; then -/bin/cat << EOF >> $xo_systemd_service +/bin/cat << EOF >> $systemd_service_dir/$xo_service # systemd service for XO-Server. [Unit] From 6922a0494472af14ef92e123ece5ceaa60819244 Mon Sep 17 00:00:00 2001 From: hooksie1 Date: Thu, 3 Aug 2017 10:55:55 -0400 Subject: [PATCH 11/13] Fix incorrect if statement variable --- xo_install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xo_install.sh b/xo_install.sh index 9150479..69fde48 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -38,7 +38,7 @@ sudo sed -i "s|#'/': '/path/to/xo-web/dist/'|'/': '/opt/xo-web/dist'|" .xo-serve cd $xo_web_dir /usr/bin/yarn install --force -if [[ ! -e $xo_systemd_service ]] ; then +if [[ ! -e $systemd_service_dir/$xo_service ]] ; then /bin/cat << EOF >> $systemd_service_dir/$xo_service # systemd service for XO-Server. From 5b9bf914f73bf1cbdf326554218ccc024dd425d5 Mon Sep 17 00:00:00 2001 From: hooksie1 Date: Thu, 3 Aug 2017 20:17:50 -0400 Subject: [PATCH 12/13] Move yarn install --force before yaml copy. --- xo_install.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/xo_install.sh b/xo_install.sh index 69fde48..fcd7b61 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -32,11 +32,10 @@ sudo /usr/bin/apt-get install --yes build-essential redis-server libpng-dev git /usr/bin/git clone -b $xo_branch $xo_server /usr/bin/git clone -b $xo_branch $xo_web cd $xo_server_dir -sudo /usr/bin/npm install && /usr/bin/npm run build +/usr/bin/yarn install --force sudo cp sample.config.yaml .xo-server.yaml sudo sed -i "s|#'/': '/path/to/xo-web/dist/'|'/': '/opt/xo-web/dist'|" .xo-server.yaml cd $xo_web_dir -/usr/bin/yarn install --force if [[ ! -e $systemd_service_dir/$xo_service ]] ; then From ba5bf945716dae4897706fea423485aef9d2b016 Mon Sep 17 00:00:00 2001 From: hooksie1 Date: Thu, 3 Aug 2017 20:24:38 -0400 Subject: [PATCH 13/13] Wasn't paying attention. Need it in both places. --- xo_install.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/xo_install.sh b/xo_install.sh index fcd7b61..250c6ba 100644 --- a/xo_install.sh +++ b/xo_install.sh @@ -36,6 +36,7 @@ cd $xo_server_dir sudo cp sample.config.yaml .xo-server.yaml sudo sed -i "s|#'/': '/path/to/xo-web/dist/'|'/': '/opt/xo-web/dist'|" .xo-server.yaml cd $xo_web_dir +/usr/bin/yarn install --force if [[ ! -e $systemd_service_dir/$xo_service ]] ; then