mirror of
https://github.com/Ravinou/borgwarehouse
synced 2024-06-10 09:52:22 +02:00
fix: stop container if init failed
This commit is contained in:
parent
22eabd165d
commit
7e21c7b379
|
@ -11,7 +11,7 @@ RUN useradd -m -g borgwarehouse borgwarehouse
|
||||||
|
|
||||||
WORKDIR /home/borgwarehouse/app
|
WORKDIR /home/borgwarehouse/app
|
||||||
|
|
||||||
RUN git clone -b v2.0 https://github.com/Ravinou/borgwarehouse.git .
|
COPY . .
|
||||||
|
|
||||||
RUN chown -R borgwarehouse:borgwarehouse * .*
|
RUN chown -R borgwarehouse:borgwarehouse * .*
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,36 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
SSH_DIR="/home/borgwarehouse/.ssh"
|
SSH_DIR="/home/borgwarehouse/.ssh"
|
||||||
AUTHORIZED_KEYS_FILE="$SSH_DIR/authorized_keys"
|
AUTHORIZED_KEYS_FILE="$SSH_DIR/authorized_keys"
|
||||||
REPOS_DIR="/home/borgwarehouse/repos"
|
REPOS_DIR="/home/borgwarehouse/repos"
|
||||||
|
|
||||||
if [ ! -d "$SSH_DIR" ]; then
|
create_ssh_directory() {
|
||||||
echo "The .ssh directory does not exist, creating..."
|
if [ ! -d "$SSH_DIR" ]; then
|
||||||
mkdir -p "$SSH_DIR"
|
echo "The .ssh directory does not exist, creating..."
|
||||||
chmod 700 "$SSH_DIR"
|
mkdir -p "$SSH_DIR"
|
||||||
fi
|
chmod 700 "$SSH_DIR"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ ! -f "$AUTHORIZED_KEYS_FILE" ]; then
|
create_authorized_keys_file() {
|
||||||
echo "The authorized_keys file does not exist, creating..."
|
if [ ! -f "$AUTHORIZED_KEYS_FILE" ]; then
|
||||||
touch "$AUTHORIZED_KEYS_FILE"
|
echo "The authorized_keys file does not exist, creating..."
|
||||||
chmod 600 "$AUTHORIZED_KEYS_FILE"
|
touch "$AUTHORIZED_KEYS_FILE"
|
||||||
fi
|
chmod 600 "$AUTHORIZED_KEYS_FILE"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
if [ ! -d "$REPOS_DIR" ]; then
|
create_repos_directory() {
|
||||||
echo "The repos directory does not exist, creating..."
|
if [ ! -d "$REPOS_DIR" ]; then
|
||||||
mkdir -p "$REPOS_DIR"
|
echo "The repos directory does not exist, creating..."
|
||||||
fi
|
mkdir -p "$REPOS_DIR"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
exec "$@"
|
create_ssh_directory
|
||||||
|
create_authorized_keys_file
|
||||||
|
create_repos_directory
|
||||||
|
|
||||||
|
exec "$@"
|
Loading…
Reference in a new issue