-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3ad061e
commit d69225e
Showing
3 changed files
with
31 additions
and
25 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
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 |
---|---|---|
|
@@ -13,24 +13,26 @@ TERMAGGRS="top,significant,rare" | |
APP_NAME="news-search-api" | ||
|
||
# Check if running as root | ||
if [[ $UID -ne 0 ]]; then | ||
echo "This script must be run as root." | ||
exit 1 | ||
fi | ||
is_root() { | ||
if [ $(whoami) != "root" ]; then | ||
echo "This script must be run as root." | ||
exit 1 | ||
fi | ||
} | ||
|
||
is_root | ||
echo "Running as root" | ||
|
||
LOGIN_USER=$(whoami) | ||
LOGIN_USER=$(who am i | awk '{ print $1 }') | ||
if [ "x$LOGIN_USER" = x ]; then | ||
# XXX fall back to whoami (look by uid) | ||
echo could not find login user 1>&2 | ||
exit 1 | ||
fi | ||
|
||
run_as_login_user() { | ||
if [ $(whoami) = root ]; then | ||
is_root | ||
su $LOGIN_USER -c "$*" | ||
else | ||
$* | ||
fi | ||
} | ||
|
||
help() | ||
|
@@ -75,7 +77,7 @@ rm -rf "$PRIVATE_CONF_DIR" | |
mkdir -p "$PRIVATE_CONF_DIR" | ||
chmod go-rwx "$PRIVATE_CONF_DIR" | ||
CONFIG_REPO_PREFIX=$(zzz [email protected]:zrqvnpybhq) | ||
CONFIG_REPO_NAME=$(zzz fgbel-vaqrkre-pbasvt) | ||
CONFIG_REPO_NAME=$(zzz arjf-frnepu-ncv-pbasvt) | ||
echo cloning $CONFIG_REPO_NAME repo 1>&2 | ||
if ! run_as_login_user "git clone $CONFIG_REPO_PREFIX/$CONFIG_REPO_NAME.git" >/dev/null 2>&1; then | ||
echo "FATAL: could not clone config repo" 1>&2 | ||
|
@@ -100,7 +102,7 @@ GH_REPO_PREFIX="https://github.com/mediacloud" | |
GH_REPO_NAME="news-search-api" | ||
DOCKER_COMPOSE_FILE="docker-compose.yml" | ||
echo "Fetching $DOCKER_COMPOSE_FILE from $GH_REPO_NAME repo..." | ||
if ! curl -sSfL "$GH_REPO_PREFIX/$GH_REPO_NAME/raw/main/$DOCKER_COMPOSE_FILE" -o "$INSTALL_DIR/$DOCKER_COMPOSE_FILE"; then | ||
if ! curl -sSfL "$GH_REPO_PREFIX/$GH_REPO_NAME/raw/$IMAGE_TAG/$DOCKER_COMPOSE_FILE" -o "$INSTALL_DIR/$DOCKER_COMPOSE_FILE"; then | ||
echo "FATAL: Could not fetch $DOCKER_COMPOSE_FILE from config repo" | ||
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