-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from JarvusInnovations/develop
Release: emergence v1.1.0
- Loading branch information
Showing
17 changed files
with
1,222 additions
and
85 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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
**/node_modules | ||
.eslintrc.json | ||
.gitignore | ||
.npmignore | ||
cloud-config.yaml | ||
Dockerfile | ||
run-dev-container |
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,6 @@ | ||
.dockerignore | ||
.eslintrc.json | ||
.gitignore | ||
cloud-config.yaml | ||
Dockerfile | ||
run-dev-container |
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,36 @@ | ||
#!/bin/bash | ||
|
||
log () { | ||
echo "emergence-certbot-auth: $@" | ||
} | ||
|
||
die () { | ||
echo >&2 "emergence-certbot-auth: $@" | ||
exit 1 | ||
} | ||
|
||
|
||
# check usage | ||
[ -n "${CERTBOT_DOMAIN}" ] || die "required environment variable missing: \$CERTBOT_DOMAIN" | ||
[ -n "${CERTBOT_VALIDATION}" ] || die "required environment variable missing: \$CERTBOT_VALIDATION" | ||
[ -n "${CERTBOT_TOKEN}" ] || die "required environment variable missing: \$CERTBOT_TOKEN" | ||
|
||
|
||
# determine location of this script | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
done | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
||
|
||
# resolve site handle for domain | ||
SITE_HANDLE="$(${DIR}/resolve-site ${CERTBOT_DOMAIN})" | ||
[ -n "${SITE_HANDLE}" ] || die "could not resolve domain '${CERTBOT_DOMAIN}' under /emergence/sites/*/site.json" | ||
|
||
|
||
# write auth file | ||
log "writing ${SITE_HANDLE}/${CERTBOT_TOKEN}" | ||
echo "${CERTBOT_VALIDATION}" | "${DIR}/write-file" "${SITE_HANDLE}" "site-root/.well-known/acme-challenge/${CERTBOT_TOKEN}" || die "failed to write token to VFS" |
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,35 @@ | ||
#!/bin/bash | ||
|
||
log () { | ||
echo "emergence-certbot-cleanup: $@" | ||
} | ||
|
||
die () { | ||
echo >&2 "emergence-certbot-cleanup: $@" | ||
exit 1 | ||
} | ||
|
||
|
||
# check usage | ||
[ -n "${CERTBOT_DOMAIN}" ] || die "required environment variable missing: \$CERTBOT_DOMAIN" | ||
[ -n "${CERTBOT_TOKEN}" ] || die "required environment variable missing: \$CERTBOT_TOKEN" | ||
|
||
|
||
# determine location of this script | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
done | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
||
|
||
# resolve site handle for domain | ||
SITE_HANDLE="$(${DIR}/resolve-site ${CERTBOT_DOMAIN})" | ||
[ -n "${SITE_HANDLE}" ] || die "could not resolve domain '${CERTBOT_DOMAIN}' under /emergence/sites/*/site.json" | ||
|
||
|
||
# delete auth file | ||
log "deleting ${SITE_HANDLE}/${CERTBOT_TOKEN}" | ||
"${DIR}/delete-file" "${SITE_HANDLE}" "site-root/.well-known/acme-challenge/${CERTBOT_TOKEN}" || die "failed to delete token from VFS" |
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,44 @@ | ||
#!/bin/bash | ||
|
||
die () { | ||
echo >&2 "$@" | ||
exit 1 | ||
} | ||
|
||
|
||
# check usage | ||
[ -n "$1" ] && [ -n "$2" ] || die "Usage: emergence-delete-file <site-handle> <site-file-path>" | ||
|
||
|
||
# determine location of this script | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
done | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
||
|
||
# execute php script | ||
cat <<'END_OF_PHP' | "${DIR}/shell" "$1" --stdin "$2" | ||
<?php | ||
$node = Site::resolvePath($argv[1]); | ||
if (!$node) { | ||
error_log('emergence-delete-file: cannot remove \''.$argv[1].'\': No such file'); | ||
exit(1); | ||
} | ||
try { | ||
$node->delete(); | ||
exit(0); | ||
} catch (Exception $e) { | ||
error_log('emergence-delete-file: failed to delete file from VFS: '.$e->getMessage()); | ||
exit(1); | ||
} | ||
END_OF_PHP | ||
|
||
|
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,39 @@ | ||
#!/bin/bash | ||
|
||
die () { | ||
echo >&2 "$@" | ||
exit 1 | ||
} | ||
|
||
|
||
# check usage | ||
[ -n "$1" ] && [ -n "$2" ] || die "Usage: emergence-read-file <site-handle> <site-file-path>" | ||
|
||
|
||
# determine location of this script | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
done | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
||
|
||
# execute php script | ||
cat <<'END_OF_PHP' | "${DIR}/shell" "$1" --stdin "$2" | ||
<?php | ||
$node = Site::resolvePath($argv[1]); | ||
if (!$node) { | ||
error_log('emergence-read-file: cannot read \''.$argv[1].'\': No such file'); | ||
exit(1); | ||
} | ||
readfile($node->RealPath); | ||
exit(0); | ||
END_OF_PHP | ||
|
||
|
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,45 @@ | ||
#!/bin/bash | ||
|
||
die () { | ||
echo >&2 "emergence-resolve-site: $@" | ||
exit 1 | ||
} | ||
|
||
|
||
# check usage | ||
[ -n "$1" ] || die "Usage: emergence-resolve-site <hostname>" | ||
[ -d "/emergence/sites" ] || die "/emergence/sites not found" | ||
|
||
|
||
# determine location of this script | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
done | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
||
|
||
# determine path to underscore | ||
UNDERSCORE="$DIR/../node_modules/.bin/underscore" | ||
|
||
|
||
# search sites | ||
pushd /emergence/sites > /dev/null | ||
for SITE_DIR in `find . -maxdepth 1 ! -path . -type d`; do | ||
SITE_HANDLE="$(basename ${SITE_DIR})" | ||
SITE_HOSTNAMES="$(sudo cat ${SITE_DIR}/site.json | $UNDERSCORE process '(data.hostnames||[]).concat([data.primary_hostname]).filter(x=>x)' --outfmt text)" | ||
|
||
for SITE_HOSTNAME in $SITE_HOSTNAMES; do | ||
if [[ "${1}" == $SITE_HOSTNAME ]]; then # NOT MATCHING WILDCARD | ||
echo "${SITE_HANDLE}" | ||
exit 0 | ||
fi | ||
done | ||
done | ||
popd > /dev/null | ||
|
||
|
||
# return failure if no match found | ||
exit 1 |
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,58 @@ | ||
#!/bin/bash | ||
|
||
die () { | ||
echo >&2 "$@" | ||
exit 1 | ||
} | ||
|
||
|
||
# check usage | ||
[ -n "$1" ] && [ -n "$2" ] || die "Usage: emergence-write-file <site-handle> <site-file-path> [host-file-path]" | ||
|
||
|
||
# determine location of this script | ||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located | ||
done | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
||
|
||
|
||
|
||
# read stdin to tmp | ||
if [ -z "${3}" ]; then | ||
# determine path to underscore | ||
UNDERSCORE="$DIR/../node_modules/.bin/underscore" | ||
|
||
# read application group name | ||
APP_GROUP="$(sudo cat /emergence/config.json | $UNDERSCORE extract --outfmt text group)" | ||
INPUT_FILE="$(mktemp)" | ||
chgrp "${APP_GROUP}" "${INPUT_FILE}" | ||
chmod g+r "${INPUT_FILE}" | ||
|
||
cat - > "${INPUT_FILE}" | ||
elif [ ! -f "${3}" ]; then | ||
die "Input file ${3} not found" | ||
else | ||
INPUT_FILE="${3}" | ||
fi | ||
|
||
|
||
# execute php script | ||
cat <<'END_OF_PHP' | exec "${DIR}/shell" "${1}" --stdin "${2}" "${INPUT_FILE}" | ||
<?php | ||
try { | ||
Emergence_FS::importFile($argv[2], $argv[1]); | ||
exit(0); | ||
} catch (Exception $e) { | ||
error_log('emergence-write-file: failed to delete file from VFS: '.$e->getMessage()); | ||
exit(1); | ||
} | ||
END_OF_PHP | ||
|
||
|
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
Oops, something went wrong.