-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not use sudo on startup (separate install from startup)
- Loading branch information
Showing
6 changed files
with
143 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
mobindi.conf | ||
.mobindi.conf.tmp | ||
node_modules | ||
local/ | ||
dist/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
INSTALL_DIR="$(dirname "$BASH_SOURCE")" | ||
|
||
cd "$INSTALL_DIR" | ||
|
||
|
||
LOGDIR="" | ||
|
||
if [ -f ./mobindi.conf ]; then | ||
. ./mobindi.conf | ||
fi | ||
|
||
UPDATECONF=0 | ||
FORCE_BUILD=0 | ||
while [ "$#" != 0 ]; do | ||
case "$1" in | ||
--log-dir) | ||
shift | ||
LOGDIR="$1" | ||
shift | ||
UPDATECONF=1 | ||
;; | ||
--no-log-dir) | ||
shift | ||
LOGDIR="" | ||
UPDATECONF=1 | ||
;; | ||
--force-build) | ||
shift | ||
FORCE_BUILD=1 | ||
;; | ||
*) | ||
echo "Usage: $0 [--log-dir logdirectory] [--no-log-dir] [--force-build]" | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
printf "Settings:\n * Log directory: %s\n" "$LOGDIR" | ||
|
||
if [ "$UPDATECONF" != 0 ]; then | ||
printf "LOGDIR='%q'" "$LOGDIR" > ./.mobindi.conf.tmp | ||
mv ./.mobindi.conf.tmp ./mobindi.conf | ||
fi | ||
|
||
if [ "${LOGDIR-}" != "" ]; then | ||
which multilog > /dev/null || (echo "Installation of daemontools required" >&2 ; sudo apt install daemontools) | ||
[ -d "$LOGDIR" ] || sudo mkdir -p -- "$LOGDIR" | ||
[ -w "$LOGDIR" ] || sudo chown "$UID" -R -- "$LOGDIR" | ||
fi | ||
|
||
# Rebuild if required | ||
CURRENTREV="`git rev-parse HEAD`" | ||
if [ "$CURRENTREV" == "" ]; then | ||
echo "Git repo is broken. Aborting" 2>&1 | ||
exit 1 | ||
fi | ||
|
||
if [ "$FORCE_BUILD" != 0 ]; then | ||
LATESTBUILD="" | ||
else | ||
ISCLEAN="`git status --porcelain`" | ||
if [ "$ISCLEAN" != "" ]; then | ||
echo "WARNING: You're git repo is not clean - Automated build cannot be deduced from local modification" 2>&1 | ||
fi | ||
if [ -f ".latestbuild" ]; then | ||
LATESTBUILD="`cat .latestbuild`" | ||
else | ||
LATESTBUILD="" | ||
fi | ||
fi | ||
|
||
if [ "$CURRENTREV" != "$LATESTBUILD" ]; then | ||
echo "Build required... Please wait" 2>&1 | ||
rm -f .latestbuild | ||
./build.sh | ||
echo "$CURRENTREV" >> .latestbuild | ||
fi | ||
|
||
# Setup nginx | ||
./nginx/install.sh | ||
|
||
echo "System ready" >&2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
INSTALL_DIR="$(dirname "$BASH_SOURCE")" | ||
|
||
cd "$INSTALL_DIR" | ||
|
||
LOGDIR="" | ||
|
||
if [ -f ../mobindi.conf ]; then | ||
. ../mobindi.conf | ||
fi | ||
|
||
[[ ":$PATH:" != *":/usr/sbin:"* ]] && PATH="${PATH}:/usr/sbin" | ||
|
||
which nginx > /dev/null || (echo "Installation of nginx required" >&2 ; sudo apt install nginx) | ||
|
||
if [ ! -f nginx-selfsigned.key ] \ | ||
|| [ ! -f nginx-selfsigned.crt ] \ | ||
|| [ "$(find nginx-selfsigned.key -mtime +360)" ] \ | ||
|| [ "$(find nginx-selfsigned.crt -mtime +360)" ]; then | ||
which openssl > /dev/null || (echo "Installation of openssl required" >&2; sudo apt install openssl) | ||
|
||
echo "SSL certificate required" >&2 | ||
|
||
openssl req -x509 -nodes -days 365 -newkey rsa:2048 \ | ||
-subj "/C=GB/ST=London/L=London/O=Global Security/OU=IT Department/CN=example.com" \ | ||
-keyout /tmp/nginx-selfsigned.key -out /tmp/nginx-selfsigned.crt | ||
|
||
mv /tmp/nginx-selfsigned.key /tmp/nginx-selfsigned.crt . | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters