add archlinux version with teleport installed
This commit is contained in:
+14
-8
@@ -1,4 +1,4 @@
|
|||||||
FROM alpine:edge
|
FROM archlinux:latest
|
||||||
|
|
||||||
ENV USER=borg
|
ENV USER=borg
|
||||||
ENV UID=1000
|
ENV UID=1000
|
||||||
@@ -15,22 +15,29 @@ VOLUME ["/backups"]
|
|||||||
VOLUME ["/logs"]
|
VOLUME ["/logs"]
|
||||||
VOLUME ["/sshkeys/host"]
|
VOLUME ["/sshkeys/host"]
|
||||||
|
|
||||||
COPY motd.txt /etc/motd
|
|
||||||
COPY entrypoint-script/entrypoint.sh /
|
COPY entrypoint-script/entrypoint.sh /
|
||||||
COPY entrypoint-script/variables.sh /
|
COPY entrypoint-script/variables.sh /
|
||||||
COPY scripts/borgbackup.sh /usr/local/bin/
|
COPY scripts/borgbackup.sh /usr/local/bin/
|
||||||
|
|
||||||
COPY bash-config/.bash_profile /root/
|
COPY bash-config/.bash_profile /root/
|
||||||
COPY bash-config/.bashrc /root/
|
COPY bash-config/.bashrc_root /root/
|
||||||
|
|
||||||
|
COPY bash-config/.bash_profile /
|
||||||
|
COPY bash-config/.bashrc /
|
||||||
|
|
||||||
COPY prometheus-borg-exporter/borg_exporter.sh /usr/local/bin/
|
COPY prometheus-borg-exporter/borg_exporter.sh /usr/local/bin/
|
||||||
COPY prometheus-borg-exporter/borg_exporter.rc /etc/
|
COPY prometheus-borg-exporter/borg_exporter.rc /etc/
|
||||||
|
|
||||||
# Install packages
|
# Install packages
|
||||||
RUN apk update ; apk upgrade
|
RUN pacman -Syu --noconfirm sudo bash-completion openssh neofetch \
|
||||||
RUN apk add --no-cache sudo bash bash-completion tzdata openssh openrc neofetch \
|
borgbackup dateutils prometheus-node-exporter wget git base-devel cron net-tools inetutils
|
||||||
borgbackup dateutils prometheus-node-exporter curl wget
|
|
||||||
RUN rm -rf /var/cache/apk/*
|
# Make Build User
|
||||||
|
RUN useradd builduser -m
|
||||||
|
RUN passwd -d builduser
|
||||||
|
RUN printf 'builduser ALL=(ALL) ALL\n' | tee -a /etc/sudoers
|
||||||
|
RUN sudo -u builduser bash -c 'cd ~ && git clone https://aur.archlinux.org/teleport-bin.git teleport && cd teleport && makepkg -si --noconfirm && cd ~ && rm -rf teleport'
|
||||||
|
RUN userdel -r builduser
|
||||||
|
|
||||||
# Setup SSH-Server
|
# Setup SSH-Server
|
||||||
RUN sed -ie 's/#Port 22/Port 22/g' /etc/ssh/sshd_config
|
RUN sed -ie 's/#Port 22/Port 22/g' /etc/ssh/sshd_config
|
||||||
@@ -40,7 +47,6 @@ RUN sed -ie 's/#PasswordAuthentication yes/PasswordAuthentication no/g' /etc/ssh
|
|||||||
RUN sed -ie 's|#HostKey /etc/ssh/ssh_host_rsa_key|HostKey /sshkeys/host/ssh_host_rsa_key|g' /etc/ssh/sshd_config
|
RUN sed -ie 's|#HostKey /etc/ssh/ssh_host_rsa_key|HostKey /sshkeys/host/ssh_host_rsa_key|g' /etc/ssh/sshd_config
|
||||||
RUN sed -ie 's|#HostKey /etc/ssh/ssh_host_ecdsa_key|HostKey /sshkeys/host/ssh_host_ecdsa_key|g' /etc/ssh/sshd_config
|
RUN sed -ie 's|#HostKey /etc/ssh/ssh_host_ecdsa_key|HostKey /sshkeys/host/ssh_host_ecdsa_key|g' /etc/ssh/sshd_config
|
||||||
RUN sed -ie 's|#HostKey /etc/ssh/ssh_host_ed25519_key|HostKey /sshkeys/host/ssh_host_ed25519_key|g' /etc/ssh/sshd_config
|
RUN sed -ie 's|#HostKey /etc/ssh/ssh_host_ed25519_key|HostKey /sshkeys/host/ssh_host_ed25519_key|g' /etc/ssh/sshd_config
|
||||||
RUN sed -ie 's|root:x:0:0:root:/root:/bin/ash|root:x:0:0:root:/root:/bin/bash|g' /etc/passwd
|
|
||||||
|
|
||||||
EXPOSE 22
|
EXPOSE 22
|
||||||
ENTRYPOINT [ "/entrypoint.sh" ]
|
ENTRYPOINT [ "/entrypoint.sh" ]
|
||||||
|
|||||||
+1
-1
@@ -1 +1 @@
|
|||||||
* * * * * /test_script.sh
|
* * * * * /test_script.sh
|
||||||
|
|||||||
+2
-77
@@ -1,4 +1,4 @@
|
|||||||
alias update='apk update && apk upgrade'
|
alias update='sudo pacman -Syu --noconfirm'
|
||||||
|
|
||||||
export HISTTIMEFORMAT="%d/%m/%y %T "
|
export HISTTIMEFORMAT="%d/%m/%y %T "
|
||||||
export PS1='\u@\h:\W \$ '
|
export PS1='\u@\h:\W \$ '
|
||||||
@@ -8,79 +8,13 @@ alias la='ls -A'
|
|||||||
alias ll='ls -alF'
|
alias ll='ls -alF'
|
||||||
alias ls='ls --color=auto'
|
alias ls='ls --color=auto'
|
||||||
|
|
||||||
source /etc/profile.d/bash_completion.sh
|
|
||||||
|
|
||||||
export PS1="\[\e[31m\][\[\e[m\]\[\e[38;5;172m\]\u\[\e[m\]@\[\e[38;5;153m\]\h\[\e[m\] \[\e[38;5;214m\]\W\[\e[m\]\[\e[31m\]]\[\e[m\]\\$ "
|
export PS1="\[\e[31m\][\[\e[m\]\[\e[38;5;172m\]\u\[\e[m\]@\[\e[38;5;153m\]\h\[\e[m\] \[\e[38;5;214m\]\W\[\e[m\]\[\e[31m\]]\[\e[m\]\\$ "
|
||||||
##############################################################################################################################
|
##############################################################################################################################
|
||||||
# Borg Repo finder
|
# Functions
|
||||||
##############################################################################################################################
|
##############################################################################################################################
|
||||||
source "/variables.sh"
|
source "/variables.sh"
|
||||||
COLUMNS=$(/usr/bin/tput cols)
|
COLUMNS=$(/usr/bin/tput cols)
|
||||||
|
|
||||||
function find_borg_repo {
|
|
||||||
repo_list=( $(find "$1" -name "index.*" -type f | rev | cut -d '/' -f "2-" | rev) )
|
|
||||||
|
|
||||||
if [ -z "$repo_list" ]; then
|
|
||||||
sepurator
|
|
||||||
echo "* Can not find borg repository"
|
|
||||||
else
|
|
||||||
sepurator
|
|
||||||
echo "* Select borg repository"
|
|
||||||
sepurator
|
|
||||||
select_borg_repo
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function select_borg_repo {
|
|
||||||
if [ "${#repo_list[@]}" -eq 1 ]; then
|
|
||||||
echo "* Only one item"
|
|
||||||
sepurator
|
|
||||||
selected_repo="0"
|
|
||||||
else
|
|
||||||
for key in "${!repo_list[@]}" ; do
|
|
||||||
echo "$key: ${repo_list[key]}"
|
|
||||||
done
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
|
|
||||||
selected_repo=asfd
|
|
||||||
while ! [[ $selected_repo -lt ${#repo_list[@]} && $selected_repo =~ ^[+]?[0-9]+$ ]]; do
|
|
||||||
read -p "Please select a Repo: " selected_repo
|
|
||||||
|
|
||||||
if [[ $selected_repo -gt $((${#repo_list[@]} -1)) ]]; then
|
|
||||||
sepurator
|
|
||||||
echo "* Oops! User input was out of range!"
|
|
||||||
sepurator
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! [[ $selected_repo =~ ^[+]?[0-9]+$ ]]; then
|
|
||||||
sepurator
|
|
||||||
echo "* Oops! User input was not a positive integer!"
|
|
||||||
sepurator
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
sepurator
|
|
||||||
}
|
|
||||||
|
|
||||||
function ask_for_repo_password {
|
|
||||||
if [ -z "$BORG_PASSPHRASE" ]; then
|
|
||||||
if grep -q 'key' "$BORG_REPO/config"; then
|
|
||||||
echo "* BORG REPO has a password"
|
|
||||||
sepurator
|
|
||||||
echo "(you can leave it empty if you not like to export BORG_PASSPHRASE)"
|
|
||||||
read -s -p "Please enter password: " BORG_REPO_PASSWORD
|
|
||||||
echo ""
|
|
||||||
if [ "$BORG_REPO_PASSWORD" != "" ]; then
|
|
||||||
export BORG_PASSPHRASE="$BORG_REPO_PASSWORD"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "* BORG REPO has no password"
|
|
||||||
fi
|
|
||||||
sepurator
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function print_container_info {
|
function print_container_info {
|
||||||
sepurator
|
sepurator
|
||||||
echo "BorgServer powered by $BORG_VERSION - Image Hostname: $HOSTNAME | Image Version: $DOCKER_IMAGE_VERSION"
|
echo "BorgServer powered by $BORG_VERSION - Image Hostname: $HOSTNAME | Image Version: $DOCKER_IMAGE_VERSION"
|
||||||
@@ -89,14 +23,5 @@ function print_container_info {
|
|||||||
##############################################################################################################################
|
##############################################################################################################################
|
||||||
# Run Code
|
# Run Code
|
||||||
##############################################################################################################################
|
##############################################################################################################################
|
||||||
if [ "$INTERACTIVE_MODE" != "false" ]; then
|
|
||||||
find_borg_repo /backups/
|
|
||||||
export BORG_REPO="${repo_list[selected_repo]}"
|
|
||||||
if [ ! -z "$BORG_REPO" ]; then
|
|
||||||
ask_for_repo_password
|
|
||||||
clear
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
print_container_info
|
print_container_info
|
||||||
neofetch
|
neofetch
|
||||||
|
|||||||
@@ -0,0 +1,100 @@
|
|||||||
|
alias update='pacman -Syu --noconfirm'
|
||||||
|
|
||||||
|
export HISTTIMEFORMAT="%d/%m/%y %T "
|
||||||
|
export PS1='\u@\h:\W \$ '
|
||||||
|
|
||||||
|
alias l='ls -CF'
|
||||||
|
alias la='ls -A'
|
||||||
|
alias ll='ls -alF'
|
||||||
|
alias ls='ls --color=auto'
|
||||||
|
|
||||||
|
export PS1="\[\e[31m\][\[\e[m\]\[\e[38;5;172m\]\u\[\e[m\]@\[\e[38;5;153m\]\h\[\e[m\] \[\e[38;5;214m\]\W\[\e[m\]\[\e[31m\]]\[\e[m\]\\$ "
|
||||||
|
##############################################################################################################################
|
||||||
|
# Borg Repo finder
|
||||||
|
##############################################################################################################################
|
||||||
|
source "/variables.sh"
|
||||||
|
COLUMNS=$(/usr/bin/tput cols)
|
||||||
|
|
||||||
|
function find_borg_repo {
|
||||||
|
repo_list=( $(find "$1" -name "index.*" -type f | rev | cut -d '/' -f "2-" | rev) )
|
||||||
|
|
||||||
|
if [ -z "$repo_list" ]; then
|
||||||
|
sepurator
|
||||||
|
echo "* Can not find borg repository"
|
||||||
|
else
|
||||||
|
sepurator
|
||||||
|
echo "* Select borg repository"
|
||||||
|
sepurator
|
||||||
|
select_borg_repo
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function select_borg_repo {
|
||||||
|
if [ "${#repo_list[@]}" -eq 1 ]; then
|
||||||
|
echo "* Only one item"
|
||||||
|
sepurator
|
||||||
|
selected_repo="0"
|
||||||
|
else
|
||||||
|
for key in "${!repo_list[@]}" ; do
|
||||||
|
echo "$key: ${repo_list[key]}"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
selected_repo=asfd
|
||||||
|
while ! [[ $selected_repo -lt ${#repo_list[@]} && $selected_repo =~ ^[+]?[0-9]+$ ]]; do
|
||||||
|
read -p "Please select a Repo: " selected_repo
|
||||||
|
|
||||||
|
if [[ $selected_repo -gt $((${#repo_list[@]} -1)) ]]; then
|
||||||
|
sepurator
|
||||||
|
echo "* Oops! User input was out of range!"
|
||||||
|
sepurator
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ $selected_repo =~ ^[+]?[0-9]+$ ]]; then
|
||||||
|
sepurator
|
||||||
|
echo "* Oops! User input was not a positive integer!"
|
||||||
|
sepurator
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
sepurator
|
||||||
|
}
|
||||||
|
|
||||||
|
function ask_for_repo_password {
|
||||||
|
if [ -z "$BORG_PASSPHRASE" ]; then
|
||||||
|
if grep -q 'key' "$BORG_REPO/config"; then
|
||||||
|
echo "* BORG REPO has a password"
|
||||||
|
sepurator
|
||||||
|
echo "(you can leave it empty if you not like to export BORG_PASSPHRASE)"
|
||||||
|
read -s -p "Please enter password: " BORG_REPO_PASSWORD
|
||||||
|
echo ""
|
||||||
|
if [ "$BORG_REPO_PASSWORD" != "" ]; then
|
||||||
|
export BORG_PASSPHRASE="$BORG_REPO_PASSWORD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "* BORG REPO has no password"
|
||||||
|
fi
|
||||||
|
sepurator
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function print_container_info {
|
||||||
|
sepurator
|
||||||
|
echo "BorgServer powered by $BORG_VERSION - Image Hostname: $HOSTNAME | Image Version: $DOCKER_IMAGE_VERSION"
|
||||||
|
sepurator
|
||||||
|
}
|
||||||
|
##############################################################################################################################
|
||||||
|
# Run Code
|
||||||
|
##############################################################################################################################
|
||||||
|
if [ "$INTERACTIVE_MODE" != "false" ]; then
|
||||||
|
find_borg_repo /backups/
|
||||||
|
export BORG_REPO="${repo_list[selected_repo]}"
|
||||||
|
if [ ! -z "$BORG_REPO" ]; then
|
||||||
|
ask_for_repo_password
|
||||||
|
clear
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
print_container_info
|
||||||
|
neofetch
|
||||||
@@ -8,6 +8,7 @@ run_docker_container() {
|
|||||||
echo "Running..."
|
echo "Running..."
|
||||||
docker run -dp 3000:22 \
|
docker run -dp 3000:22 \
|
||||||
-p 9100:9100 \
|
-p 9100:9100 \
|
||||||
|
-p 2222:22 \
|
||||||
-e UID=$(id -u) \
|
-e UID=$(id -u) \
|
||||||
-e GID=$(id -g) \
|
-e GID=$(id -g) \
|
||||||
-e MAINTENANCE_ENABLE="true" \
|
-e MAINTENANCE_ENABLE="true" \
|
||||||
|
|||||||
@@ -18,16 +18,15 @@ function print_user_info {
|
|||||||
|
|
||||||
function add_borg_user {
|
function add_borg_user {
|
||||||
if ! id "$USER" &>/dev/null; then
|
if ! id "$USER" &>/dev/null; then
|
||||||
sh -c "echo '$USER ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers"
|
groupadd -g "$GID" "$USER" >> /dev/null
|
||||||
adduser \
|
useradd -r -u "$UID" -g "$GID" -s "/bin/bash" "$USER" >> /dev/null
|
||||||
-s /bin/bash \
|
passwd -d "$USER" >> /dev/null
|
||||||
--disabled-password \
|
printf "$USER ALL=(ALL) NOPASSWD: ALL\n" | tee -a /etc/sudoers >> /dev/null
|
||||||
--gecos "" \
|
usermod -d / borg >> /dev/null
|
||||||
--home "/" \
|
|
||||||
--uid "$UID" \
|
create_folder_and_change_permissions "/.config"
|
||||||
"$USER"
|
create_folder_and_change_permissions "/.cache"
|
||||||
echo "$USER:*" | chpasswd 2>> /dev/null
|
chmod 700 "/.cache"
|
||||||
addgroup -g "$GID" "$USER" 2>> /dev/null
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,8 +111,8 @@ function maintenance_enable {
|
|||||||
echo "* MAINTENANCE MODE - ENABLED"
|
echo "* MAINTENANCE MODE - ENABLED"
|
||||||
echo ""
|
echo ""
|
||||||
if [ -f "/crontab.txt" ]; then
|
if [ -f "/crontab.txt" ]; then
|
||||||
/usr/bin/crontab "/crontab.txt"
|
crontab "/crontab.txt"
|
||||||
/usr/sbin/crond -b 2> /dev/null
|
crond -i 2> /dev/null
|
||||||
echo "- Crontab loaded successfully"
|
echo "- Crontab loaded successfully"
|
||||||
else
|
else
|
||||||
echo "- Can not find /crontab.txt"
|
echo "- Can not find /crontab.txt"
|
||||||
@@ -152,12 +151,20 @@ function create_folder_and_change_permissions {
|
|||||||
chown -R "$USER":"$USER" "$1"
|
chown -R "$USER":"$USER" "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function run_teleport_server() {
|
||||||
|
if [ -f "/etc/teleport.yaml" ]; then
|
||||||
|
echo "* STARTING Teleport Server"
|
||||||
|
teleport start -c /etc/teleport.yaml > /var/log/teleport.log 2>&1 &
|
||||||
|
sepurator
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function run_prometheus_exporter() {
|
function run_prometheus_exporter() {
|
||||||
if [ "$RUN_PROMETHEUS_EXPORTER" != "false" ]; then
|
if [ "$RUN_PROMETHEUS_EXPORTER" != "false" ]; then
|
||||||
create_folder_and_change_permissions "/.config"
|
|
||||||
create_folder_and_change_permissions "/var/log/"
|
create_folder_and_change_permissions "/var/log/"
|
||||||
|
|
||||||
echo "* STARTING Prometheus Exporter for Borg Backup"
|
echo "* STARTING Prometheus Exporter for Borg Backup"
|
||||||
|
echo ""
|
||||||
|
|
||||||
crontab -l > /tmp/cron_bkp
|
crontab -l > /tmp/cron_bkp
|
||||||
echo "" >> /tmp/cron_bkp
|
echo "" >> /tmp/cron_bkp
|
||||||
@@ -173,7 +180,7 @@ function run_prometheus_exporter() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "- STARTING Node Exporter"
|
echo "- STARTING Node Exporter"
|
||||||
sudo -H -u "$USER" bash -c "node_exporter --collector.textfile.directory=$NODE_EXPORTER_DIR &"
|
sudo -H -u "$USER" bash -c "prometheus-node-exporter --collector.textfile.directory=$NODE_EXPORTER_DIR > /dev/null 2>&1 &"
|
||||||
sepurator
|
sepurator
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -192,6 +199,7 @@ sepurator
|
|||||||
|
|
||||||
maintenance_enable
|
maintenance_enable
|
||||||
set_timezone
|
set_timezone
|
||||||
|
run_teleport_server
|
||||||
run_prometheus_exporter
|
run_prometheus_exporter
|
||||||
run_install_script
|
run_install_script
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user