From 33097ac42a40fd71e20e16b4007af44c2f9b8f08 Mon Sep 17 00:00:00 2001 From: Daniel Dolezal Date: Fri, 1 Jul 2022 14:42:12 +0200 Subject: [PATCH] add bash ui when load and install neofetch --- .bash_profile | 13 ++++++++++ .bashrc | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 1 + Dockerfile | 5 +++- entrypoint.sh | 1 + 5 files changed, 88 insertions(+), 1 deletion(-) create mode 100644 .bash_profile create mode 100644 .bashrc diff --git a/.bash_profile b/.bash_profile new file mode 100644 index 0000000..0551e69 --- /dev/null +++ b/.bash_profile @@ -0,0 +1,13 @@ +# .bash_profile + +# Get the aliases and functions +if [ -f ~/.bashrc ]; then + . ~/.bashrc +fi + +# User specific environment and startup programs + +PATH=$PATH:$HOME/bin + +export PATH +unset USERNAME \ No newline at end of file diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..8cdc6c0 --- /dev/null +++ b/.bashrc @@ -0,0 +1,69 @@ +alias update='apk update && apk upgrade' + +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' + +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\]\\$ " +############################################################################################################################## +# Borg Repo finder +############################################################################################################################## +function sepurator { + echo "===============================================================================" +} + +function find_borg_repo { + repo_list=( $(find "$1" -name "index.*" -type f | rev | cut -d '/' -f "2-" | rev) ) + + if [ -z "$repo_list" ]; then + echo "* Can not find borg repository" + exit 1 + 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 +} + +find_borg_repo backups/ +export BORG_REPO="${repo_list[selected_repo]}" +clear +neofetch diff --git a/.gitignore b/.gitignore index ea20769..6546af6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ sshkeys/clients/ sshkeys/host/ crontab.txt maintain_repo.sh +backups/ diff --git a/Dockerfile b/Dockerfile index a0016a7..4a369b1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -15,9 +15,12 @@ VOLUME ["/sshkeys/host"] COPY motd.txt /etc/motd COPY entrypoint.sh / +COPY .bash_profile /root/ +COPY .bashrc /root/ + # Install packages RUN apk update ; apk upgrade -RUN apk add --no-cache sudo bash tzdata openssh-server openrc \ +RUN apk add --no-cache sudo bash bash-completion tzdata openssh-server openrc neofetch \ borgbackup RUN rm -rf /var/cache/apk/* diff --git a/entrypoint.sh b/entrypoint.sh index b5c83e6..c46cf36 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -26,6 +26,7 @@ function add_borg_user { if ! id "borg" &>/dev/null; then sh -c "echo '$USER ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers" adduser \ + -s /bin/bash \ --disabled-password \ --gecos "" \ --home "/" \