Skip to content

Commit

Permalink
Format all files with shfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
MrNaif2018 committed Sep 18, 2021
1 parent 34b6aa9 commit 5df42c8
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 25 deletions.
7 changes: 3 additions & 4 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,15 @@
set -e

: "${BITCARTGEN_DOCKER_IMAGE:=bitcartcc/docker-compose-generator}"
if [ "$BITCARTGEN_DOCKER_IMAGE" == "bitcartcc/docker-compose-generator:local" ]
then
if [ "$BITCARTGEN_DOCKER_IMAGE" == "bitcartcc/docker-compose-generator:local" ]; then
docker build generator --tag $BITCARTGEN_DOCKER_IMAGE
else
set +e
docker pull $BITCARTGEN_DOCKER_IMAGE
docker rmi $(docker images bitcartcc/docker-compose-generator --format "{{.Tag}};{{.ID}}" | grep "^<none>" | cut -f2 -d ';') > /dev/null 2>&1
docker rmi $(docker images bitcartcc/docker-compose-generator --format "{{.Tag}};{{.ID}}" | grep "^<none>" | cut -f2 -d ';') >/dev/null 2>&1
set -e
fi

docker run -v "$PWD/compose:/app/compose" \
--env-file <(env | grep BITCART_) \
--rm $BITCARTGEN_DOCKER_IMAGE
--rm $BITCARTGEN_DOCKER_IMAGE
2 changes: 1 addition & 1 deletion changedomain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ export BITCART_HOST="$NEW_HOST"

bitcart_update_docker_env
apply_local_modifications
bitcart_start
bitcart_start
2 changes: 1 addition & 1 deletion cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env bash

docker image prune -af --filter "label=org.bitcartcc.image" --filter "label!=org.bitcartcc.image=docker-compose-generator"
docker image prune -af --filter "label=org.bitcartcc.image" --filter "label!=org.bitcartcc.image=docker-compose-generator"
10 changes: 5 additions & 5 deletions compose/scripts/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ set -ex
# BitcartCC is configuring current instance or updating it via SSH access

# Make host.docker.internal work (on linux-based docker engines)
echo "$(/sbin/ip route|awk '/default/ { print $3 }') host.docker.internal" >> /etc/hosts
echo "$(/sbin/ip route | awk '/default/ { print $3 }') host.docker.internal" >>/etc/hosts

if [ ! -z "$SSH_KEY_FILE" ] && ! [ -f "$SSH_KEY_FILE" ]; then
echo "Creating BitcartCC SSH key File..."
ssh-keygen -t rsa -f "$SSH_KEY_FILE" -q -P "" -m PEM -C bitcartcc > /dev/null
ssh-keygen -t rsa -f "$SSH_KEY_FILE" -q -P "" -m PEM -C bitcartcc >/dev/null
if [ -f "$SSH_AUTHORIZED_KEYS" ]; then
# Because the file is mounted, sed -i does not work
sed '/bitcartcc$/d' "$SSH_AUTHORIZED_KEYS" > "$SSH_AUTHORIZED_KEYS.new"
cat "$SSH_AUTHORIZED_KEYS.new" > "$SSH_AUTHORIZED_KEYS"
sed '/bitcartcc$/d' "$SSH_AUTHORIZED_KEYS" >"$SSH_AUTHORIZED_KEYS.new"
cat "$SSH_AUTHORIZED_KEYS.new" >"$SSH_AUTHORIZED_KEYS"
rm -rf "$SSH_AUTHORIZED_KEYS.new"
fi
fi

if [ ! -z "$SSH_KEY_FILE" ] && [ -f "$SSH_AUTHORIZED_KEYS" ] && ! grep -q "bitcartcc$" "$SSH_AUTHORIZED_KEYS"; then
echo "Adding BitcartCC SSH key to authorized keys"
cat "$SSH_KEY_FILE.pub" >> "$SSH_AUTHORIZED_KEYS"
cat "$SSH_KEY_FILE.pub" >>"$SSH_AUTHORIZED_KEYS"
fi

exec "$@"
14 changes: 7 additions & 7 deletions helpers.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[[ -f ".deploy" ]] && . .deploy

bitcart_update_docker_env() {
touch $BITCART_ENV_FILE
cat > $BITCART_ENV_FILE << EOF
touch $BITCART_ENV_FILE
cat >$BITCART_ENV_FILE <<EOF
BITCART_HOST=$BITCART_HOST
BITCART_LETSENCRYPT_EMAIL=$BITCART_LETSENCRYPT_EMAIL
REVERSEPROXY_HTTP_PORT=$REVERSEPROXY_HTTP_PORT
Expand Down Expand Up @@ -68,7 +68,7 @@ get_profile_file() {
fi
if [[ -z $(grep ". \"$BASH_PROFILE_SCRIPT\"" "$HOME/.bash_profile") ]]; then
# Line does not exist, add it
echo ". \"$BASH_PROFILE_SCRIPT\"" >> "$HOME/.bash_profile"
echo ". \"$BASH_PROFILE_SCRIPT\"" >>"$HOME/.bash_profile"
fi

else
Expand Down Expand Up @@ -99,7 +99,7 @@ remove_host() {

add_host() {
if [ -z "$(grep -P "[[:space:]]$2" /etc/hosts)" ]; then
try printf "%s\t%s\n" "$1" "$2" | sudo tee -a /etc/hosts > /dev/null
try printf "%s\t%s\n" "$1" "$2" | sudo tee -a /etc/hosts >/dev/null
fi
}

Expand All @@ -109,9 +109,9 @@ modify_host() {
}

apply_local_modifications() {
if [[ "$BITCART_HOST" == *.local ]] ; then
if [[ "$BITCART_HOST" == *.local ]]; then
echo "Local setup detected."
if [[ "$BITCART_NOHOSTSEDIT" = true ]] ; then
if [[ "$BITCART_NOHOSTSEDIT" = true ]]; then
echo "Not modifying hosts."
else
echo "WARNING! Modifying /etc/hosts to make local setup work. It may require superuser privileges."
Expand All @@ -132,7 +132,7 @@ bitcart_dump_db() {
if [ ! -d "$backup_dir" ]; then
docker volume create backup_datadir
fi
docker exec $(container_name "database_1") pg_dumpall -c -U postgres > "$backup_dir/$1"
docker exec $(container_name "database_1") pg_dumpall -c -U postgres >"$backup_dir/$1"
}

bitcart_restore_db() {
Expand Down
2 changes: 1 addition & 1 deletion load_env.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env bash

. helpers.sh
load_env
load_env
2 changes: 1 addition & 1 deletion restart.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
load_env

cd "$BITCART_BASE_DIRECTORY"
bitcart_restart
bitcart_restart
2 changes: 1 addition & 1 deletion start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
load_env

cd "$BITCART_BASE_DIRECTORY"
bitcart_start
bitcart_start
2 changes: 1 addition & 1 deletion stop.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
load_env

cd "$BITCART_BASE_DIRECTORY"
bitcart_stop
bitcart_stop
6 changes: 3 additions & 3 deletions update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
. helpers.sh
load_env

export USER_UID=${UID}
export USER_UID=${UID}
export USER_GID=${GID}

cd "$BITCART_BASE_DIRECTORY"
Expand All @@ -20,7 +20,7 @@ if ! [ -f "/etc/docker/daemon.json" ] && [ -w "/etc/docker" ]; then
echo "{
\"log-driver\": \"json-file\",
\"log-opts\": {\"max-size\": \"5m\", \"max-file\": \"3\"}
}" > /etc/docker/daemon.json
}" >/etc/docker/daemon.json
echo "Setting limited log files in /etc/docker/daemon.json"
fi

Expand All @@ -35,4 +35,4 @@ bitcart_pull
bitcart_start

set +e
docker image prune -af --filter "label=org.bitcartcc.image" --filter "label!=org.bitcartcc.image=docker-compose-generator"
docker image prune -af --filter "label=org.bitcartcc.image" --filter "label!=org.bitcartcc.image=docker-compose-generator"

0 comments on commit 5df42c8

Please sign in to comment.