├── .bash_aliases ├── .bash_prompt ├── .zshrc-personal ├── 1-install.sh ├── 2-install.sh ├── 3-interface.sh ├── ARRstack ├── .env └── compose.yml ├── BashAddon.sh ├── Docker ├── dockge.yml ├── music.yml ├── nginxpm.yml ├── portainer_agent.yml ├── portainer_ce.yml └── reade.me ├── Functions ├── 2FA-TOTP ├── FOSS ├── JumpBox-Dialog ├── JumpBox-Whiptail ├── PveNewInstallHeader2 ├── askLicens ├── c-info-mTB ├── copy ├── funcColors ├── funcDebCEPH ├── funcDebReboot ├── funcDebUpdate ├── funcHOSTS ├── funcHyrrä ├── funcMainAsk ├── funcSetRoot ├── funcSpinner ├── funcSpinnerRun ├── funcStopNotRoot ├── fundDebReposBookworm ├── getPool ├── header-2 ├── header-cu1 ├── sectionBreakes ├── setLAN ├── setOptions ├── setUser ├── shebang └── version ├── LICENSE ├── README.md ├── StopDelCorosync.sh ├── WOL.sh ├── add-a-app └── main.function ├── deltest.sh ├── dns ├── config │ ├── db.192.168.1 │ ├── db.lab-example.com.zone │ └── named.conf ├── dhcp │ ├── data │ │ └── dhcpd.conf │ └── docker-compose.yml └── docker-compose.yml ├── dozzle └── docker-compose.yml ├── heimdall └── docker-compose.yml ├── interface ├── authelia-cfg-auth ├── authelia-cfg-site ├── authelia-config.yml ├── authelia.yml ├── authelia_ghost_rule ├── npm.yml └── users ├── monitorProxmox.yml ├── myTemplateBuilder.sh ├── myUpdater.sh ├── myVMsetup.sh ├── scripts ├── ColorTest.sh ├── DoDoDeb.sh ├── DoDoU.sh ├── K0s-starter.sh ├── LynisInstall.sh ├── MinSSDwear.sh ├── QuickLynis.sh ├── README.md ├── StopDelCorosync.sh ├── TemplateBuilder.sh ├── aplineInstallNFS.sh ├── compareFiles.sh ├── cpuVxSUPPORT.sh ├── debInstallNFS.sh ├── figurine.sh ├── initPVE.sh ├── initVM.sh ├── my.wol.nodes ├── myTemplateBuilder.sh ├── newBashAddon ├── wolstart └── wolstart.sh ├── showIPconfig.sh ├── sshr ├── templatebuilder.sh ├── unboundpi.yml └── watchtower └── docker-compose.yml /.bash_aliases: -------------------------------------------------------------------------------- 1 | # Some more aliases use in .bash_aliases or .bashrc-personal 2 | # restart by source .bashrc or restart 3 | # restart by . ~/.bash_aliases 4 | 5 | ### Functions go here. Use as any ALIAS ### 6 | # make a directory and jump into it 7 | mkcd() { mkdir -p "$1" && cd "$1"; } 8 | # make, chmod and nano a new script 9 | newsh() { touch "$1".sh && chmod +x "$1".sh && echo "#!/bin/bash" > "$1.sh" && nano "$1".sh; } 10 | # create, cmod and nano a file 11 | newfile() { touch "$1" && chmod 700 "$1" && nano "$1"; } 12 | new700() { touch "$1" && chmod 700 "$1" && nano "$1"; } 13 | new750() { touch "$1" && chmod 750 "$1" && nano "$1"; } 14 | new755() { touch "$1" && chmod 755 "$1" && nano "$1"; } 15 | newxfile() { touch "$1" && chmod +x "$1" && nano "$1"; } 16 | 17 | ## Other ways of doing it ## 18 | #alias mkcd='function _mkcd() { mkdir -p "$1" && cd "$1"; }; _mkcd' 19 | #newsh() { 20 | # touch "$1" && chmod +x "$1" && echo "#!/bin/bash" > "$1" && nano "$1" 21 | #} 22 | #alias newfile='f() { touch "$1" && chmod 700 "$1" && nano "$1"; }; f' 23 | 24 | ## ls commands 25 | alias ls='ls --color=auto' 26 | alias ll='ls -alFh --color=auto' 27 | alias la='ls -A' 28 | alias l='ls -CF' 29 | alias lsd='lsblk -o +MODEL,SERIAL' 30 | alias lsdid='ls -l /dev/disk/by-id' 31 | #alias ls='exa' 32 | #alias ls='exa -T' 33 | #alias ll='exa -a' 34 | #### Remvove the --icons if or install a Nerdfont 35 | #alias exa='exa --long --icons' 36 | #alias exat='exa --long --icons --tree ' 37 | alias exa='exa --long' 38 | alias exat='exa --long --tree ' 39 | 40 | ## confirm before overwriting something 41 | alias cp='cp -i' 42 | alias mv='mv -i' 43 | alias rm='rm -i' 44 | 45 | ## Colorize grep output (good for log files) 46 | alias grep='grep --color=auto' 47 | alias egrep='egrep --color=auto' 48 | alias fgrep='fgrep --color=auto' 49 | 50 | ## docker related 51 | alias docker-compose='docker compose' 52 | alias dcn='nano docker-compose.yml' 53 | alias dcup='docker-compose up -d' 54 | alias dcupl='docker-compose up -d && docker-compose logs -f' 55 | alias dcr='docker-compose restart' 56 | alias dcd='docker-compose down' 57 | 58 | ## ssh keys 59 | alias newkey='ssh-keygen -t ed25519 -C "user@example.com" -f ${1}' 60 | alias remkey='ssh-keygen -f "/etc/ssh/ssh_known_hosts" -R "${1}"' 61 | alias addkey='ssh-copy-id -i ~/.ssh/id_ed25519.pub ${1} ' 62 | 63 | ## system related on any deb based use batcat all other use bat 64 | # Set the TZ 65 | alias setz="timedatectl set-timezone $1" 66 | alias fzfbat='fzf --preview "batcat --color=always --style=numbers --line-range=:500 {}"' 67 | # usage: help 68 | #alias bathelp='bat --plain --language=help' 69 | #help() { "$@" --help 2>&1 | bathelp } 70 | # zsh only! ---------------------------------------------------------# 71 | #alias -g -- -h='-h 2>&1 | bat --language=help --style=plain' # 72 | #alias -g -- --help='--help 2>&1 | bat --language=help --style=plain' # 73 | # -------------------------------------------------------------------# 74 | alias bat='batcat' 75 | #alias cat='bat' 76 | #alias cat='batcat' 77 | #alias catt='cat' 78 | alias sr='sudo reboot' 79 | alias bye='sudo poweroff' 80 | alias update='sudo apt-get update' 81 | alias install='sudo apt-get update && sudo apt-get install -y ' 82 | #alias install='sudo nala install -y ' 83 | #alias update='sudo nala update' 84 | #alias upgrade='sudo nala upgrade --no-autoremove' 85 | #alias upall='sudo nala update && sudo nala upgrade' 86 | alias upgrade='sudo apt-get upgrade' 87 | alias upall='sudo apt-get update && sudo apt-get dist-upgrade -y' 88 | alias nhost='sudo nano /etc/hosts' 89 | alias df='df -h' 90 | alias free='free -m' 91 | alias f2b='fail2ban-regex systemd-journal /etc/fail2ban/filter.d/proxmox.conf' 92 | 93 | ## cd aliases 94 | alias 'cd..'='cd ..' 95 | alias ..='cd ..' 96 | alias ...='cd ../..' 97 | alias ....='cd ../../..' 98 | 99 | ## IP related 100 | #### Use your subnet mask here /24 /64 101 | alias myip="echo My LAN-ip: $(ip address | grep /24 | awk '{print $2}')" 102 | #alias lanip="ip a | grep inet | awk '{print $2}' | cut -f2 -d:" 103 | #alias wanip='echo WanIp: $(curl ipinfo.io/ip)' 104 | #alias netspeed='sudo curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3 -' 105 | # colored GCC warnings and errors 106 | #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' 107 | 108 | #alias sää='curl wttr.in' 109 | #alias mikä='curl cheat.sh/' 110 | 111 | # Extracting archive files 112 | # # usage: ex 113 | ex () 114 | { 115 | if [ -f $1 ] ; then 116 | case $1 in 117 | *.tar.bz2) tar xjf $1 ;; 118 | *.tar.gz) tar xzf $1 ;; 119 | *.bz2) bunzip2 $1 ;; 120 | *.rar) unrar x $1 ;; 121 | *.gz) gunzip $1 ;; 122 | *.tar) tar xf $1 ;; 123 | *.tbz2) tar xjf $1 ;; 124 | *.tgz) tar xzf $1 ;; 125 | *.zip) unzip $1 ;; 126 | *.Z) uncompress $1;; 127 | *.7z) 7z x $1 ;; 128 | *.deb) ar x $1 ;; 129 | *.tar.xz) tar xf $1 ;; 130 | *.tar.zst) tar xf $1 ;; 131 | *) echo "'$1' cannot be extracted via ex()" ;; 132 | esac 133 | else 134 | echo "'$1' is not a valid file" 135 | fi 136 | } 137 | 138 | # Use Personal Prompt 139 | [[ -f ~/.bash_prompt ]] && source ~/.bash_prompt 140 | 141 | 142 | -------------------------------------------------------------------------------- /.bash_prompt: -------------------------------------------------------------------------------- 1 | #Jay’s custom bash prompt 2 | # Save that file, and then open up your ~/.bashrc or ~/.bash_aliases or ~/.bashrc-personal 3 | # and place the following at the end of the file: source ~/.bash_prompt 4 | 5 | BRACKET_COLOR="\[\033[38;5;35m\]" 6 | CLOCK_COLOR="\[\033[38;5;35m\]" 7 | JOB_COLOR="\[\033[38;5;33m\]" 8 | PATH_COLOR="\[\033[38;5;33m\]" 9 | LINE_BOTTOM="\342\224\200" 10 | LINE_BOTTOM_CORNER="\342\224\224" 11 | LINE_COLOR="\[\033[38;5;248m\]" 12 | LINE_STRAIGHT="\342\224\200" 13 | LINE_UPPER_CORNER="\342\224\214" 14 | END_CHARACTER="|" 15 | 16 | tty -s && export PS1="$LINE_COLOR$LINE_UPPER_CORNER$LINE_STRAIGHT$LINE_STRAIGHT$BRACKET_COLOR[$CLOCK_COLOR\t$BRACKET_COLOR]$LINE_COLOR$LINE_STRAIGHT$BRACKET_COLOR[$JOB_COLOR\j$BRACKET_COLOR]$LINE_COLOR$LINE_STRAIGHT$BRACKET_COLOR[\H:\]$PATH_COLOR\w$BRACKET_COLOR]\n$LINE_COLOR$LINE_BOTTOM_CORNER$LINE_STRAIGHT$LINE_BOTTOM$END_CHARACTER\[$(tput sgr0)\] " 17 | -------------------------------------------------------------------------------- /.zshrc-personal: -------------------------------------------------------------------------------- 1 | # My personal aliases 2 | 3 | # Set the theme 4 | #ZSH_THEME="powerlevel10k/powerlevel10k" 5 | 6 | # User configuration 7 | plugins=(git zsh-autosuggestions zsh-syntax-highlighting web-search) 8 | 9 | ### Functions go here. Use as any ALIAS ### 10 | # make a directory and jump into it 11 | mkcd() { mkdir -p "$1" && cd "$1"; } 12 | # make, chmod and nano/vim a new script 13 | newsh() { touch "$1".sh && chmod +x "$1".sh && echo "#!/bin/bash" > "$1.sh" && nano "$1".sh; } 14 | # create, cmod and nano a file 15 | newfile() { touch "$1" && chmod 700 "$1" && nano "$1"; } 16 | new700() { touch "$1" && chmod 700 "$1" && nano "$1"; } 17 | new750() { touch "$1" && chmod 750 "$1" && nano "$1"; } 18 | new755() { touch "$1" && chmod 755 "$1" && nano "$1"; } 19 | newxfile() { touch "$1" && chmod +x "$1" && nano "$1"; } 20 | 21 | # atuin 22 | echo 'eval "$(atuin init zsh)"' >> ~/.zshrc 23 | 24 | # My aliases 25 | # exa 26 | alias exa='eza --long --icons' 27 | alias exat='eza --long --icons --tree' 28 | alias exaa='eza --all --icons' 29 | alias exaat='eza --all --long --icons --tree' 30 | 31 | #alias eza='eza --long --icons' 32 | #alias ezat='eza --long --icons --tree' 33 | #alias ezaa='eza --all --icons' 34 | #alias ezxaat='eza --all --long --icons --tree' 35 | 36 | # bat related 37 | #alias bat=batcat 38 | alias fzfb='fzf --preview "batcat --color=always --style=numbers --line-range=:500 {}"' 39 | 40 | #fzf alias 41 | alias fzfp="find /home/$USER -type f | fzf --preview 'less {}'" 42 | alias fzfcd='cd $(find /home/$USER -type d | fzf)' 43 | alias fzycd='cd $(find -type d | fzy)' 44 | # bat related 45 | #alias bathelp='bat --plain --language=help' 46 | #help() { 47 | # "$@" --help 2>&1 | bathelp 48 | #} 49 | #alias -g -- -h='-h 2>&1 | bat --language=help --style=plain' 50 | #alias -g -- --help='--help 2>&1 | bat --language=help --style=plain' 51 | 52 | # git 53 | alias gita='git add .' # add all 54 | alias gitp='git push origin main' 55 | alias gitc='git commit -m ${1}' 56 | 57 | # vim 58 | alias vim='nvim' 59 | alias v='nvim' 60 | 61 | ## ls commands 62 | alias ls="eza --icons --group-directories-first" # 'ls --color=auto' 63 | alias ll="eza --icons --group-directories-first -l" #'ls -alFh --color=auto' 64 | alias la="eza --icons --group-directories-first -a" # 'ls -A' 65 | alias l='ls -CF' 66 | alias lsdisk='lsblk -o +MODEL,SERIAL' 67 | alias lsdid='ls -l /dev/disk/by-id' 68 | alias lsuuid='ls -l /dev/disk/by-uuid/' 69 | 70 | ######## 71 | ## docker related 72 | alias dcn='nano docker-compose.yml' 73 | alias dcup='docker-compose up -d' 74 | alias dcupl='docker-compose up -d && docker-compose logs -f' 75 | alias dcr='docker-compose restart' 76 | alias dcd='docker-compose down' 77 | 78 | # ssh-keys 79 | # Adds your keyphrase to the ssh/agent for this session 80 | alias ssha='eval $(ssh-agent) && ssh-add' 81 | # Copy a SSH/key to a server 82 | alias sshc='ssh-copy-id -i ~/.ssh/"$1".pub' 83 | # newkey -C = Your comment -f = your filname 84 | # Use: newkey "your_comment_here" "path_to_key_file" 85 | newkey() { 86 | ssh-keygen -t ed25519 -C "$1" -f "$2" 87 | } 88 | alias remkey='ssh-keygen -f "/etc/ssh/ssh_known_hosts" -R "$1"' 89 | # Use: addkey "file" "server" 90 | addkey() { 91 | ssh-copy-id -i ~/.ssh/$1.pub $2 92 | } 93 | 94 | ## system related 95 | 96 | # Set the TZ 97 | alias setz="timedatectl set-timezone $1" 98 | 99 | alias bye='sudo poweroff' 100 | 101 | ## cd aliases 102 | alias 'cd..'='cd ..' 103 | alias ..='cd ..' 104 | alias ...='cd ../..' 105 | alias ....='cd ../../..' 106 | 107 | ## IP related 108 | # IPv4 /24 IPv6 /64 - Or use your subnet mask here 109 | #$(ip address| awk '/inet/ {print $2}' | grep -v ^::1 | grep -v ^127) 110 | alias myip="echo My LAN-ip: $(ip address | grep /24 | awk '{print $2}')" 111 | alias lanip="ip a | grep inet | awk '{print $2}' | cut -f2 -d:" 112 | alias wanip='echo WanIp: $(curl ipinfo.io/ip)' 113 | alias netspeed='sudo curl -s https://raw.githubusercontent.com/sivel/speedtest-cli/master/speedtest.py | python3 -' 114 | alias myips=nmcli -p device show 115 | #alias myip=./printIP.sh 116 | 117 | # Other 118 | alias sää='curl wttr.in' 119 | alias mikä='curl cheat.sh/' 120 | 121 | # colored GCC warnings and errors 122 | #export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' 123 | -------------------------------------------------------------------------------- /1-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Obsolete see the newmyVMsetup.sh 3 | #--------------------------------------------------------# 4 | # 1-install.sh 2.0 Part 1 of the Journey # 5 | # MyJourney project homelab.casaursus.net # 6 | # # 7 | # V.1 Created by Nalle Juslen 10.01.2022 as 2 scripts # 8 | # -review 9.2.2022 # 9 | # # 10 | # V.2 created 10.02.2022 Prepare VM for Docker-Stack # 11 | # - revison # 12 | #--------------------------------------------------------# 13 | 14 | # Declare function hyrraPyorii Show a activity spinner --# 15 | hyrraPyorii (){ # 16 | pid=$! # Process Id of the previous running command # 17 | x='-\|/' # hyrra in its elements # 18 | i=0 # 19 | while kill -0 $pid 2>/dev/null # 20 | do # 21 | i=$(( (i+1) %4 )) # 22 | printf "\r ${x:$i:1}" # 23 | sleep .1 # 24 | done # 25 | printf "\r " # 26 | } # 27 | hyrraPyorii # 28 | # -------------------------------------------------------# 29 | 30 | clear 31 | echo "" 32 | echo "Starting upgrade/install of apps for the Docker-stack" 33 | echo "" 34 | echo " WARNING - DON'T run scripts without editing - WARNING" 35 | echo "" 36 | echo " Warning . This script will pull parts from my GitHub" 37 | echo "" 38 | lsb_release -a #print lsb-release info 39 | echo "" 40 | echo "Preparing the VM" 41 | # Add bash_aliases ------------------------------------------------------------ 42 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/.bash_aliases &> /dev/null 43 | . ~/.bash_aliases 44 | echo " - added .bash_aliases" 45 | # running install ------------------------------------------------------------- 46 | echo "" 47 | echo " - starting Install" 48 | echo " WARNING Rread the code - edit and the run!" 49 | read -rp " - Do you want to do the Install [y/n] " DPI 50 | if [[ "$DPI" = [yY] ]]; then 51 | echo " - Running VM updates and installs ..." 52 | # This is the main part update-install-upgrade ------------------------------ 53 | echo "**** Initial install/upgrade stage **** **** ****" > ~/install.log 54 | sudo ls &> /dev/null # dummy to get sudo psw 55 | (sudo apt-get update && 56 | sudo apt-get install curl apt-transport-https ca-certificates software-properties-common fail2ban -y && 57 | sudo apt-get upgrade -y 58 | ) >> ~/install.log 2>&1 & 59 | hyrraPyorii 60 | echo " - starting Docker Pre-Install ..." 61 | echo "**** Docker Pre Install stage **** **** ****" >> ~/install.log 62 | wget https://github.com/nallej/MyJourney/raw/main/LICENSE &> /dev/null 63 | # set your timezone --------------------------------------------------------- 64 | echo " - TZ = Helsinki" # change to your timezone 65 | sudo timedatectl set-timezone Europe/Helsinki 66 | # --------------------------------------------------------------------------- 67 | read -rp " - Are you ruinning 1-Focal 2-Hirsute 0=Quit : " OS # <<< add deb 68 | echo " - LTS is recomended use Focal Stable" 69 | if [[ "$OS" != [1] ]]; then 70 | echo "You need to edit the script" 71 | exit 72 | else 73 | echo " ... upgrading sw ..." 74 | echo "**** second install/upgrade stage **** **** ****" >> ~/install.log 75 | ( # Add keys ----------------------------------------------------------- 76 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && 77 | sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" && 78 | # LTS is recomendded focal stable (hirsute, impish) ------------------ 79 | sudo apt-cache policy docker-ce && 80 | sudo apt-get update && 81 | sudo apt-get upgrade -y 82 | ) >> ~/install.log 2>&1 & 83 | hyrraPyorii 84 | fi 85 | echo "" 86 | echo " - Setting up unattenden updates = yes " 87 | echo "**** Docker Pre Install stage **** **** ****" >> ~/install.log 88 | (sudo systemctl enable unattended-upgrades --now) >> ~/install.log 2>&1 & 89 | echo "" 90 | echo " WARNING - Do you want to clear old updates?" 91 | read -rp " - Clear old updates [y/n] " COU 92 | if [[ "$COU" = [yY] ]]; then 93 | echo " - Deliting old installs ..." 94 | (sudo apt-get clean && 95 | sudo apt-get autoremove) >> ~/install.log 2>&1 & 96 | fi 97 | 98 | # This is only needed for Proxmox VM's ------------------------# 99 | echo "" # 100 | read -rp " - Install QGA for Proxmox VM [y/n] " QGA # 101 | if [[ "$QGA" = [yY] ]]; then # 102 | sudo apt-get install -q -y qemu-guest-agent &> /dev/null # 103 | fi # 104 | # qemu-quest-agent --------------------------------------------# 105 | 106 | # Giv your stack a name or use default: docker-stack -------------------------- 107 | mkdir docker-stack 108 | cd docker-stack 109 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/2-install.sh &> /dev/null 110 | chmod +x 2-install.sh 111 | # ============================================================================= 112 | echo "" 113 | echo "" 114 | echo "" 115 | echo "All done ! " 116 | echo " - Licens copied to current folder " 117 | echo " - Next script is in ~/docker-stack/ - 2-install.sh " 118 | echo " - install.log written, check for errors " 119 | echo "" 120 | echo "" 121 | echo "Ready for the next script ? " 122 | echo " - Read the code, change to your needs, add your stuff and passwords ! " 123 | echo " - reboot is mandatory" 124 | echo "" 125 | echo "You should now: " 126 | echo " - Power off and change VM settings " 127 | echo " - Edit the script: ~/docker-stack/2-install.sh " 128 | echo "" 129 | sleep 2s 130 | read -rp "Do you want to reboot? [y/n] " RB 131 | if [[ "$RB" = [yY] ]]; then 132 | sudo reboot 133 | fi 134 | # end of install y/n 135 | else 136 | echo "Exit - automated process" 137 | echo " - Edit the script: ~/docker-stack/2-install.sh " 138 | echo " - Read the code, change to your needs, add your stuff and passwords ! " 139 | echo " - REBOOT befor running ./2-install.sh" 140 | fi 141 | -------------------------------------------------------------------------------- /2-install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Obsolete see the newmyVMsetup.sh 3 | #--------------------------------------------------------# 4 | # 2-install.sh 2.0 # 5 | # MyJourney project # 6 | # # 7 | # V.1 created by Nalle Juslen 20.11.2021 as 2 scripts # 8 | # - revison 26.1.2022 # 9 | # # 10 | # V.2 created 15.02.2022 Install basic Docker-Stack # 11 | # - revision # 12 | #--------------------------------------------------------# 13 | 14 | # Declare function hyrraPyorii Show a activity spinner --# 15 | hyrraPyorii (){ # 16 | pid=$! # Process Id of the previous running command # 17 | x='-\|/' # hyrra in its elements # 18 | i=0 # 19 | while kill -0 $pid 2>/dev/null # 20 | do # 21 | i=$(( (i+1) %4 )) # 22 | printf "\r ${x:$i:1}" # 23 | sleep .1 # 24 | done # 25 | printf "\r " # 26 | } # 27 | hyrraPyorii # 28 | # -------------------------------------------------------# 29 | 30 | clear 31 | echo "This script will install:" 32 | echo " - Docker-ce and Docker-Compose," 33 | echo " - Portainer/Portainer agent, " 34 | echo " - Dozzle and Watchtower, " 35 | echo " - if you need it Heimdall. " 36 | echo "" 37 | echo " WARNING - DON'T run scripts without editing - WARNING" 38 | echo "" 39 | echo " Warning . This script will pull parts from my GitHub" 40 | echo "" 41 | echo "" 42 | # What to install ------------------------------------------------------------- 43 | echo "Chose apps to install:" 44 | read -rp " Docker-ce [y/n] " DOCE 45 | read -rp " Docker-Compose [y/n] " DOCO 46 | echo "Use Portainer or the Agent " 47 | read -rp " - Portainer-ce [y/n] " POT 48 | read -rp " - Portainer Agent [y/n] " POTA 49 | echo "" 50 | echo "Recommended apps:" 51 | read -rp " WatchTower [y/n] " WT 52 | read -rp " Dozzle [y/n] " DOZ 53 | echo "" 54 | echo "Optional apps " 55 | read -rp " - Heimdall [y/n] " HEIM 56 | 57 | 58 | # Start installing Docker-ce -------------------------------------------------- 59 | if [[ "$DOCE" == [yY] ]]; then 60 | #sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" 61 | #apt-cache policy docker-ce 62 | sudo ls &> /dev/null # dummy to get sudo psw 63 | echo "" 64 | echo "installing Docker-ce" 65 | (sudo apt install -q docker-ce -y ) >> ~/install.log 2>&1 & 66 | hyrraPyorii 67 | echo "" 68 | echo " - Docker-ce installed. " 69 | echo " - Starting docker." 70 | echo "" 71 | sleep 10s 72 | sudo systemctl enable docker 73 | sudo systemctl enable containerd.service 74 | sudo systemctl start docker 75 | sleep 5s 76 | docker -v 77 | sleep 2s 78 | sudo usermod -aG docker "${USER}" # you do not need to sudo to run docker commands after re-login 79 | sleep 1s 80 | sudo docker network create -d bridge kadulla &> /dev/null #frontend 81 | sudo docker network create -d bridge pihalla &> /dev/null #backbone 82 | echo " $USER added to docker group" 83 | echo "" 84 | echo " Internal networks created:" 85 | echo " - kadulla = frontend " 86 | echo " - pihalla = backbone " 87 | echo "" 88 | fi 89 | echo "" 90 | 91 | # Start installing Docker-Copmpose -------------------------------------------- 92 | if [[ "$DOCO" == [yY] ]]; then 93 | (sudo apt install -q docker-compose -y) >> ~/install.log 2>&1 & 94 | hyrraPyorii 95 | echo "" 96 | echo " - Docker-Compose installed." 97 | echo "" 98 | fi 99 | echo "" 100 | # Start installing Portainer/Portainer agent ---------------------------------- 101 | echo "" 102 | #---------------------------------------------# 103 | # I use 9000 http, you can use 9443 for https # 104 | #---------------------------------------------# 105 | if [[ "$POT" == [yY] ]]; then 106 | (sudo docker volume create portainer_data 107 | sudo docker run -d \ 108 | -p 8000:8000 \ 109 | -p 9000:9000 \ 110 | --name=portainer \ 111 | --restart=always \ 112 | -v /var/run/docker.sock:/var/run/docker.sock \ 113 | -v portainer_data:/data \ 114 | portainer/portainer-ce) >> ~/install.log 2>&1 & 115 | hyrraPyorii 116 | echo " - Portainer @ x.x.x.x:9000" 117 | echo "" 118 | fi 119 | if [[ "$POTA" == [yY] ]]; then 120 | echo "" 121 | echo "" 122 | (sudo docker volume create portainer_data 123 | sudo docker run -d \ 124 | -p 9001:9001 \ 125 | --name portainer_agent \ 126 | --restart=always \ 127 | -v /var/run/docker.sock:/var/run/docker.sock \ 128 | -v /var/lib/docker/volumes:/var/lib/docker/volumes \ 129 | portainer/agent) >> ~/install.log 2>&1 & 130 | hyrraPyorii 131 | sleep 2s 132 | echo "" 133 | echo " - Portainer finds this agent @ x.x.x.x:9001" 134 | echo "" 135 | fi 136 | sleep 2s 137 | echo "" 138 | # Start installing WatchTower, auto update ------------------------------------ 139 | if [[ "$WT" == [yY] ]]; then 140 | mkdir ~/docker-stack/watchtower 141 | cd ~/docker-stack/watchtower 142 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/watchtower/docker-compose.yml &> /dev/null 143 | # docker-compose up -d # uncomment if you want to start now 144 | echo "" 145 | echo "Watchtower installed" 146 | echo " - Updating images daily 04.00 " 147 | echo " - NOT started, edit befor starting" 148 | echo "" 149 | fi 150 | 151 | echo "" 152 | # Start installing Dozzle, log reader ----------------------------------------- 153 | if [[ "$DOZ" == [yY] ]]; then 154 | mkdir ~/docker-stack/dozzle 155 | cd ~/docker-stack/dozzle 156 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/dozzle/docker-compose.yml &> /dev/null 157 | # sudo docker-compose up -d # uncomment if you want to start now 158 | echo "" 159 | echo "Dozzle installed" 160 | echo " - Not started, EDIT befor using" 161 | echo " - ports: 9999" 162 | echo "" 163 | fi 164 | echo "" 165 | # Start installing Heimdall, internal portal ---------------------------------- 166 | if [[ "$HEIM" == [yY] ]]; then 167 | mkdir ~/docker-stack/heimdall 168 | cd ~/docker-stack/heimdall 169 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/heimdall/docker-compose.yml &>/dev/null 170 | # docker-compose up -d # uncomment if you want to start now 171 | echo "" 172 | echo "Heimdal installed" 173 | echo " - Not started, EDIT befor using" 174 | echo " - default user/group: 1000/1000" 175 | echo " - ports: 9080 or 9088 " 176 | echo "" 177 | fi 178 | echo "" 179 | echo "Basic installation done!" 180 | echo " - add services: prometheus, node-reporter, backup ..." 181 | echo " - add your apps wp, ghost ...." 182 | echo " - logout and login again to activate permissions" 183 | echo " - reboot befor starting apps" 184 | echo "" 185 | echo "Rememper to have fun! Learn new things and love the CLI." 186 | -------------------------------------------------------------------------------- /3-interface.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Obsolete see the newmyVMsetup.sh 3 | #--------------------------------------------------------# 4 | # 3-interface.sh 1.0 # 5 | # MyJourney project | Web facing apps NPM, Authelia # 6 | # # 7 | # V.1 created by Nalle Juslen 01.03.2022 # 8 | # - revison 00.00.2022 # 9 | # # 10 | # V.2 created 15.02.2022 # 11 | # - revision 00.00.2022 # 12 | #--------------------------------------------------------# 13 | # Declare function hyrraPyorii Show a activity spinner # 14 | hyrraPyorii (){ # 15 | pid=$! # Process Id of the previous running command # 16 | x='-\|/' # hyrra in its elements # 17 | i=0 # 18 | while kill -0 $pid 2>/dev/null # 19 | do # 20 | i=$(( (i+1) %4 )) # 21 | printf "\r ${x:$i:1}" # 22 | sleep .1 # 23 | done # 24 | printf "\r " # 25 | } # 26 | hyrraPyorii # 27 | # -------------------------------------------------------# 28 | 29 | clear 30 | echo "This script will install: " 31 | echo " Interface module: " 32 | echo " - Nginx Proxy Manager " 33 | echo " - Authelia " 34 | echo " - Dozzle " 35 | echo "" 36 | echo " WARNING - DON'T run scripts without editing - WARNING " 37 | echo "" 38 | echo " Warning . This script will pull parts from my GitHub " 39 | echo "" 40 | echo "" 41 | # What to install ------------------------------------------------------------- 42 | echo "Chose apps to install:" 43 | read -rp " Nginx Proxy Manager [y/n] " NPM 44 | read -rp " Authelia [y/n] " AUTH 45 | echo "" 46 | echo "Recommended apps: " 47 | read -rp " Dozzle [y/n] " DOZ 48 | echo "" 49 | echo "Updating and Upgrading " 50 | sudo ls &> /dev/null # dummy to get sudo psw 51 | (sudo apt-get update && sudo apt-get upgrade && 52 | sleep 2s 53 | ) > ~/interface.log 2>&1 & 54 | hyrraPyorii 55 | # Start installing NPM -------------------------------------------------------- 56 | if [[ "$NPM" == [yY] ]]; then 57 | sudo ls &> /dev/null # dummy to get sudo psw 58 | echo "" 59 | echo "Installing Nginx Reverse Proxy " 60 | (mkdir -p npm npm/data npm/advanced-cfgs npm/letsencrypt npm/secrets && 61 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/interface/npm.yml -O ./npm/docker-compose.yml && 62 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/interface/authelia-cfg-site -O ./npm/advanced-cfgs/site.cfg && 63 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/interface/authelia-cfg-auth -O ./npm/advanced-cfgs/auth.cfg 64 | ) >> ~/interface.log 2>&1 & 65 | echo "" 66 | echo " - NPM installed. " 67 | echo " - Start after edits: goto npm/ and dcup (docker-compose up -d) " 68 | fi 69 | # Start installing Authelia --------------------------------------------------- 70 | if [[ "$AUTH" == [yY] ]]; then 71 | echo "" 72 | echo "Installing Authelia " 73 | (mkdir -p authelia authelia/config authelia/mysql authelia/redis && 74 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/interface/authelia.yml -O ./authelia/docker-compose.yml && 75 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/interface/authelia-config.yml -O ./authelia/config/configuration.yml && 76 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/interface/authelia-users -O ./authelia/config/users.yml 77 | ) >> ~/interface.log 2>&1 & 78 | echo "" 79 | echo " - Authelia installed " 80 | echo " - edit and test NPM before continuing! " 81 | echo " - add users passwords - use generator site " 82 | echo " - Start after edits: goto authelia/ and dcup (docker-compose up -d) " 83 | fi 84 | # Start installing Dozzle, log reader ----------------------------------------- 85 | if [[ "$DOZ" == [yY] ]]; then 86 | echo "" 87 | echo "Installing Dozzle " 88 | mkdir dozzle 89 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/Dozzle/docker-compose.yml -O ./dozzle/docker-compose.yml &> /dev/null 90 | echo "" 91 | echo " - Dozzle installed " 92 | echo " - Not started, EDIT befor using " 93 | echo " - port: 9999 " 94 | echo " - Start after edits: goto dozzle/ and dcup (docker-compose up -d) " 95 | echo "" 96 | fi 97 | echo "" 98 | echo "Interface installation done!" 99 | echo " - add your services: whoogle, wp, ghost ..." 100 | echo " - reboot befor starting up containers" 101 | echo "" 102 | echo "Rememper to have fun! Learn new things and love the CLI." 103 | sleep 2s 104 | read -rp "Do you want to reboot? [y/n] " RB 105 | if [[ "$RB" = [yY] ]]; then 106 | sudo reboot 107 | else 108 | echo "Exit - automated process" 109 | echo " - Edit the scripts! " 110 | echo " - Set re-directs in router" 111 | echo " - Read the code, change to your needs, add your stuff and passwords ! " 112 | echo " - REBOOT befor running containers" 113 | fi 114 | -------------------------------------------------------------------------------- /ARRstack/.env: -------------------------------------------------------------------------------- 1 | # Main path for all my ARR apps: 2 | ARRPATH=/media/Arr/ # in Windows it will be ARRPATH=C:\a_folder\Arr\ 3 | 4 | # Global Variables 5 | # Running as a non sudo user 6 | # Better to use rootless Docker 7 | PUID=1000 8 | PGID=1000 9 | TZ=Europe/Helsinki 10 | -------------------------------------------------------------------------------- /ARRstack/compose.yml: -------------------------------------------------------------------------------- 1 | --- 2 | # The full ARR stack 3 | services: 4 | prowlarr: 5 | image: linuxserver/prowlarr:latest 6 | container_name: prowlarr 7 | hostname: prowlarr 8 | volumes: 9 | - ${ARRPATH}Prowlarr/config:/config 10 | - ${ARRPATH}Prowlarr/backup:/data/Backup 11 | - ${ARRPATH}Downloads:/downloads 12 | ports: # Consider what port to use, 'com port':'fixed, app internal' 13 | - 9696:9696 14 | restart: unless-stopped 15 | env_file: 16 | - '.env' 17 | # ------------------------------------------------------ 18 | sonarr: 19 | image: linuxserver/sonarr:latest 20 | container_name: sonarr 21 | hostname: sonarr 22 | volumes: 23 | - ${ARRPATH}Sonarr/config:/config 24 | - ${ARRPATH}Sonarr/backup:/data/Backup 25 | - ${ARRPATH}Sonarr/tvshows:/data/tvshows 26 | - ${ARRPATH}Downloads:/downloads 27 | ports: # Consider what port to use, 'com port':'fixed, app internal' 28 | - 8989:8989 29 | restart: unless-stopped 30 | env_file: 31 | - '.env' 32 | # ------------------------------------------------------ 33 | radarr: 34 | image: linuxserver/radarr:latest 35 | container_name: radarr 36 | hostname: radarr 37 | volumes: 38 | - ${ARRPATH}Radarr/config:/config 39 | - ${ARRPATH}Radarr/movies:/data/movies 40 | - ${ARRPATH}Radarr/backup:/data/Backup 41 | - ${ARRPATH}Downloads:/downloads 42 | ports: # Consider what port to use, 'com port':'fixed, app internal' 43 | - 7878:7878 44 | restart: unless-stopped 45 | env_file: 46 | - '.env' 47 | # ------------------------------------------------------ 48 | lidarr: 49 | image: linuxserver/lidarr:latest 50 | container_name: lidarr 51 | hostname: lidarr 52 | volumes: 53 | - ${ARRPATH}Lidarr/config:/config 54 | - ${ARRPATH}Lidarr/music:/data/musicfolder 55 | - ${ARRPATH}Downloads:/downloads 56 | ports: # Consider what port to use, 'com port':'fixed, app internal' 57 | - 8686:8686 58 | restart: unless-stopped 59 | env_file: 60 | - '.env' 61 | # ------------------------------------------------------ 62 | readarr: 63 | image: linuxserver/readarr:develop 64 | container_name: readarr 65 | hostname: readarr 66 | volumes: 67 | - ${ARRPATH}Readarr/config:/config 68 | - ${ARRPATH}Readarr/books:/data/books 69 | - ${ARRPATH}Downloads:/downloads 70 | ports: 71 | - 8787:8787 # Consider what port to use, 'com port':'fixed, app internal' 72 | restart: unless-stopped 73 | env_file: 74 | - '.env' 75 | # ------------------------------------------------------ 76 | homarr: 77 | container_name: homarr 78 | image: ghcr.io/ajnart/homarr:latest 79 | restart: unless-stopped 80 | volumes: 81 | - ${ARRPATH}Homarr/configs:/app/data/configs 82 | - ${ARRPATH}Homarr/icons:/app/public/icons 83 | - ${ARRPATH}Homarr/data:/data 84 | ports: 85 | - '7575:7575' # Consider what port to use, 'com port':'fixed, app internal' 86 | env_file: 87 | - '.env' 88 | # ------------------------------------------------------ 89 | jellyfin: 90 | image: linuxserver/jellyfin 91 | container_name: jellyfin 92 | ports: # Consider what port to use, 'com port':'fixed, app internal' 93 | - '8096:8096/tcp' # Jellyfin web interface 94 | - '7359:7359/udp' # Network discovery 95 | - '1900:1900/udp' # DLNA port 96 | volumes: 97 | - ${ARRPATH}Jellyfin/config:/config 98 | - ${ARRPATH}Radarr/movies:/data/Movies 99 | - ${ARRPATH}Sonarr/tvshows:/data/TVShows 100 | - ${ARRPATH}Lidarr/music:/data/Music 101 | - ${ARRPATH}Readarr/books:/data/Books 102 | env_file: 103 | - '.env' 104 | restart: unless-stopped 105 | # ------------------------------------------------------ 106 | qbittorrent: 107 | image: linuxserver/qbittorrent:latest 108 | container_name: qbittorrent 109 | hostname: qbittorrent 110 | restart: unless-stopped 111 | labels: 112 | - "com.centurylinklabs.watchtower.enable=false" 113 | volumes: 114 | - ${ARRPATH}qbittorrent/config:/config 115 | - ${ARRPATH}Downloads:/downloads 116 | ports: # Consider what port to use, 'com port':'fixed, app internal' 117 | - 8080:8080 118 | - 6881:6881 119 | - 6881:6881/udp 120 | environment: 121 | - WEBUI_PORT=8080 122 | - TORRENTING_PORT=6881 123 | healthcheck: 124 | start_period: 15s 125 | env_file: 126 | - '.env' 127 | # ======================================================== 128 | -------------------------------------------------------------------------------- /BashAddon.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | clear 4 | echo "This script will add my personal preferenses to Proxmox nodes" 5 | echo "" 6 | echo " Adding bat (cat on steroids) to your system" 7 | # Add bat 8 | apt update && apt install -y bat >>install.log 2>&1 9 | echo " Adding aliases to your bash and a new prompt" 10 | # Add to or change the bash commands 1>>$ok_log 2>>$ei_log 11 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/.bash_aliases >>wget.log 2>&1 12 | # And also the personal bash prompt 13 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/.bash_prompt >>wget.log 2>&1 14 | # Activate the changes 15 | echo "" 16 | echo "" 17 | echo " Adding bash_aliases to bashrc" 18 | echo "[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases" >> .bashrc 19 | echo "" 20 | echo " Edit your new bash by nano .bash_aliases and make it yours" 21 | echo " - change the IP mask if not /24 in [alias myip]" 22 | echo " - add any alias you like" 23 | echo " - comment out what you do not like" 24 | echo " - exit from bat type q" 25 | sleep 1 26 | echo "" 27 | echo "To start using the new bash, type: . .bash_aliases (note the periods)" 28 | -------------------------------------------------------------------------------- /Docker/dockge.yml: -------------------------------------------------------------------------------- 1 | version: "3.8" 2 | services: 3 | dockge: 4 | ports: 5 | - 5001:5001 6 | container_name: Dockge 7 | restart: unless-stopped 8 | volumes: 9 | - /var/run/docker.sock:/var/run/docker.sock 10 | - /home/$USER/docker/dockge/data:/app/data 11 | - /home/$USER/docker/stacks:/home/$USER/docker/stacks 12 | environment: 13 | - DOCKGE_STACKS_DIR=/home/$USER/docker/stacks 14 | image: louislam/dockge:latest 15 | networks: {} 16 | -------------------------------------------------------------------------------- /Docker/music.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | services: 3 | navidrome: 4 | image: deluan/navidrome:latest 5 | ports: 6 | - "4533:4533" 7 | environment: 8 | ND_SCANINTERVAL: 15m 9 | ND_LOGLEVEL: info 10 | ND_BASEURL: "" 11 | volumes: 12 | - "./data:/data" 13 | - "./data/music:/music:ro" 14 | 15 | networks: 16 | default: 17 | name: kadulla 18 | external: true 19 | -------------------------------------------------------------------------------- /Docker/nginxpm.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | app: 4 | image: 'jc21/nginx-proxy-manager:latest' 5 | restart: unless-stopped 6 | ports: 7 | - '80:80' 8 | - '81:81' 9 | - '443:443' 10 | volumes: 11 | - ./data:/data 12 | - ./letsencrypt:/etc/letsencrypt 13 | 14 | networks: 15 | default: 16 | name: kadulla 17 | external: true 18 | -------------------------------------------------------------------------------- /Docker/portainer_agent.yml: -------------------------------------------------------------------------------- 1 | version: '3.3' 2 | services: 3 | agent: 4 | ports: 5 | - '9001:9001' 6 | container_name: portainer_agent 7 | restart: always 8 | volumes: 9 | - '/var/run/docker.sock:/var/run/docker.sock' 10 | - '/var/lib/docker/volumes:/var/lib/docker/volumes' 11 | image: portainer/agent 12 | 13 | networks: 14 | default: 15 | name: kadulla 16 | external: true 17 | -------------------------------------------------------------------------------- /Docker/portainer_ce.yml: -------------------------------------------------------------------------------- 1 | version: '3.3' 2 | services: 3 | portainer-ce: 4 | ports: 5 | - '8000:8000' 6 | - '9000:9000' 7 | container_name: portainer 8 | restart: always 9 | volumes: 10 | - '/var/run/docker.sock:/var/run/docker.sock' 11 | - './portainer_data:/data' 12 | image: portainer/portainer-ce 13 | 14 | networks: 15 | default: 16 | name: kadulla 17 | external: true 18 | -------------------------------------------------------------------------------- /Docker/reade.me: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Functions/2FA-TOTP: -------------------------------------------------------------------------------- 1 | CODE=$(whiptail --title "Two Factor Authentication" \ 2 | --passwordbox "Enter code:" 8 32 \ 3 | 3>&1 1>&2 2>&3 3>&-); clear 4 | USEC=$(sed -n 1p $HOME/.google_authenticator) 5 | TOTP=$(oathtool --totp -b $USEC) 6 | 7 | if [[ $CODE -ne $TOTP ]]; then whiptail --title "Error Detected" --msgbox "Wrong Code!" --ok-button "exit" 5 24; clear; exit 1 8 | else 9 | fi 10 | -------------------------------------------------------------------------------- /Functions/FOSS: -------------------------------------------------------------------------------- 1 | "Support FOSS" \ 2 | "Supporting the software's development team is essential for keeping it FOSS. \ 3 | Give them a Star, donate work or funds, bye coffe or bye a lisence. \ 4 | Without dedicated work by professionals, we wouldn't have this fantastic software." 5 | -------------------------------------------------------------------------------- /Functions/JumpBox-Dialog: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CODE=$(dialog --title "Two Factor Authentication" \ 4 | --clear --insecure --passwordbox "Enter your 2FA Code:" 5 36 \ 5 | 3>&1 1>&2 2>&3 3>&-); clear 6 | USEC=$(sed -n 1p $HOME/.google_authenticator) 7 | TOTP=$(oathtool --totp -b $USEC) 8 | 9 | if [[ $CODE -ne $TOTP ]]; then dialog --title "Error Detected" --msgbox "Wrong Code!" 5 24; clear; exit 1 10 | 11 | else 12 | 13 | OPT=$(dialog --menu "Select Target:" 0 0 0 \ 14 | 1 "Docker 1" \ 15 | 2 "Docker 7" \ 16 | 3 "DNS main" \ 17 | 4 "K8s master" \ 18 | 5 "NAS" \ 19 | 6 "Exit" \ 20 | 3>&1 1>&2 2>&3 3>&-); clear 21 | case $OPT in 22 | 1) ssh root@10.10.100.2 ; exit ;; 23 | 2) ssh root@10.10.100.3 ; exit ;; 24 | 3) ssh root@10.10.100.4 ; exit ;; 25 | 4) ssh root@10.10.100.5 ; exit ;; 26 | 5) ssh root@10.10.100.6 ; exit ;; 27 | *) exit ;; 28 | esac 29 | fi 30 | -------------------------------------------------------------------------------- /Functions/JumpBox-Whiptail: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CODE=$(whiptail --title "Two Factor Authentication" \ 4 | --passwordbox "Enter code:" 8 32 \ 5 | 3>&1 1>&2 2>&3 3>&-); clear 6 | USEC=$(sed -n 1p $HOME/.google_authenticator) 7 | TOTP=$(oathtool --totp -b $USEC) 8 | 9 | if [[ $CODE -ne $TOTP ]]; then whiptail --title "Error Detected" --msgbox "Wrong Code!" --ok-button "exit" 5 24; clear; exit 1 10 | 11 | else 12 | 13 | OPT=$(Whiptail --menu "Select Target:" 16 24 8 \ 14 | 1 "Docker 1" \ 15 | 2 "Docker 7" \ 16 | 3 "DNS main" \ 17 | 4 "K8s master" \ 18 | 5 "NAS" \ 19 | 6 "Exit" \ 20 | 3>&1 1>&2 2>&3 3>&-); clear 21 | case $OPT in 22 | 1) ssh root@10.10.100.2 ; exit ;; 23 | 2) ssh root@10.10.100.3 ; exit ;; 24 | 3) ssh root@10.10.100.4 ; exit ;; 25 | 4) ssh root@10.10.100.5 ; exit ;; 26 | 5) ssh root@10.10.100.6 ; exit ;; 27 | *) exit ;; 28 | esac 29 | fi 30 | -------------------------------------------------------------------------------- /Functions/PveNewInstallHeader2: -------------------------------------------------------------------------------- 1 | 2 | function header_2() { # The Script Header 3 | clear 4 | cat <<"EOF" 5 | 6 | ____ _ _ ___ _ _ _ 7 | | _ \__ _____ | \ | | _____ __ |_ _|_ __ ___| |_ __ _| | | 8 | | |_) \ \ / / _ \ | \| |/ _ \ \ /\ / / | || '_ \/ __| __/ _` | | | 9 | | __/ \ V / __/ | |\ | __/\ V V / | || | | \__ \ || (_| | | | 10 | |_| \_/ \___| |_| \_|\___| \_/\_/ |___|_| |_|___/\__\__,_|_|_| 11 | 12 | 13 | EOF 14 | } 15 | ##--------------------------------------------------------------------------------## 16 | -------------------------------------------------------------------------------- /Functions/askLicens: -------------------------------------------------------------------------------- 1 | function askLicens() { 2 | if (whiptail --backtitle "$backTEXT" --title "Copyrigt and License" --defaultno --yesno \ 3 | "\n$cstring\n⚠️ Do You Accept the LICENSE?" 20 78 \ 4 | --no-button "No" --yes-button "Accept"); then 5 | echo "${grn}User Accepted the License. Yes, exit status was $?.${end}" >> $logFILE 6 | FILE=LICENSE 7 | if [ -f "$FILE" ]; then 8 | echo "${blu}LICENSE file exist in this directory.${end}" >> $logFILE 9 | else 10 | wget https://github.com/nallej/MyJourney/raw/main/LICENSE &> /dev/null 11 | echo "${blu}LICENSE file now in this directory.${end}" >> $logFILE 12 | echo -e "\nTemplate Builder is Free and Open Sourse Software.\n - There is NO WARRANTY, to the extent permitted by law.\n - Part of the My Journey Project @ homelab.casaursus.net" > /etc/motd 13 | fi 14 | else 15 | echo "${red}⚠ User selected to Decline, exit status was $?. ⚠${end}" >> $logFILE 16 | exit 17 | fi 18 | 19 | whiptail --backtitle "$backTEXT" --title "Version History" --msgbox "$version" 18 78 20 | } 21 | -------------------------------------------------------------------------------- /Functions/c-info-mTB: -------------------------------------------------------------------------------- 1 | c-info() { # Function: printing Copyright and Version 2 | clear 3 | cat <<"EOF" 4 | 5 | Copyright (c) 2021-2023 CasaUrsus 6 | Author: nallej (CasaUrsus) 7 | License: MIT 8 | Browser: https://github.com/nallej/MyJourney/raw/main/LICENSE 9 | 10 | This is Free and Open Sourse Software; you are free to change and redistribute it. 11 | - See the LICENSE file or the link for details. 12 | - There is NO WARRANTY, read the code befor using it. 13 | 14 | TempBuilder.sh 15 | - Part of the MyJourney project @ homelab.casaursus.net 16 | - https://homelab.casaursus.net/proxmox-automation 17 | - https://homelab.casaursus.net/setting-up-kubernetes-k8s 18 | 19 | Version History: 20 | - v1.0 29.11.2022 v1.1 01.12.2022 21 | - v2.0 04.01.2023 v2.1 09.01.2023 v2.2 29.01.2023 22 | - v3.0 30.05.2023 v3.1 31.05.2023 v3.2 01.06.2023 v3.3 12.10.2023 23 | - v4.0 12.10.2023 v4.1 31.10.2023 24 | - v5.0 25.11.2023 25 | 26 | EOF 27 | } 28 | -------------------------------------------------------------------------------- /Functions/copy: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Copyright (c) 2019-2024 CasaUrsus 4 | # Author: nalle (CasaUrsus) 5 | # License: MIT 6 | # https://github.com/nallej/MyJourne/raw/main/LICENSE 7 | -------------------------------------------------------------------------------- /Functions/funcColors: -------------------------------------------------------------------------------- 1 | function useColors() { # define colors to be used 2 | # color code color as bold 3 | RED=$'\e[31m'; REDB=$'\e[1;31m' # call red with $red and bold as $redb 4 | GRN=$'\e[32m'; GRNB=$'\e[1;32m' # call as green $grn as bold green $grnb 5 | YEL=$'\e[33m'; YELB=$'\e[1;33m' # call as yellow $yel as bold yellow $yelb 6 | BLU=$'\e[34m'; BLUB=$'\e[1;34m' # call as blue $blu as bold blue $blub 7 | MAG=$'\e[35m'; MAGB=$'\e[1;35m' # call as magenta $mag as bold magenta $magb 8 | CYN=$'\e[36m'; CYNB=$'\e[1;36m' # call as cyan $cyn as cyan bold $cynb 9 | ENDC=$'\e[0m' # End that color 10 | OKCM="${GRNB}✔ ${ENDC}" # Green OK 11 | NOCM="${REDB}✘ ${ENDC}" # Red NO 12 | DASH="-" # Print a: - 13 | DLCM="${grnb}➟ ${ENDC}" # Indikate DownLoad 14 | STCM="${cynb}➲ ${ENDC}" # Start of somthing 15 | CCL="\\r\\e[K" # Clear Current Line (carriage return + clear from cursor to EOL) 16 | time=${CYNB}$(date +"%T")${ENDC} # Show time of somthing 17 | #Use them to print with colours: printf "%s\n" "Text in white ${BLU}blue${ENDC}, white and ${MAG}magenta${ENDC}. 18 | } 19 | -------------------------------------------------------------------------------- /Functions/funcDebCEPH: -------------------------------------------------------------------------------- 1 | function CEPH() { # CEPH Repos 2 | ## CEPH Package Repositories ---------------------------------------------------## 3 | CHOICE=$(whiptail --backtitle "CasaUrsus Debian Scripts" --title "CEPH REPOSITORIES" --menu "The 'CEPH Package Repos' provides access to both the 'no-subscription' and 'enterprise' repositories (all initially disabled).\n \nCorrect 'ceph package sources?" 14 58 2 \ 4 | "yes" " " \ 5 | "no" " " 3>&2 2>&1 1>&3) 6 | case $CHOICE in 7 | yes) 8 | msg_info "Correcting 'ceph package repositories'" 9 | cat </etc/apt/sources.list.d/ceph.list 10 | # deb http://download.proxmox.com/debian/ceph-quincy bookworm enterprise 11 | # deb http://download.proxmox.com/debian/ceph-quincy bookworm no-subscription 12 | # deb http://download.proxmox.com/debian/ceph-reef bookworm enterprise 13 | # deb http://download.proxmox.com/debian/ceph-reef bookworm no-subscription 14 | EOF 15 | msg_ok "Corrected CEPH repositories" 16 | ;; 17 | no) 18 | msg_error "Selected not to Correct CEPH package repositories'" 19 | ;; 20 | esac 21 | } 22 | -------------------------------------------------------------------------------- /Functions/funcDebReboot: -------------------------------------------------------------------------------- 1 | function reboot() { # reboot the server 2 | CHOICE=$(whiptail --backtitle "CasaUrsus Debian Scripts" --title "REBOOT" --menu "\nReboot Server now? (recommended)" 11 58 2 \ 3 | "yes" " " \ 4 | "no" " " 3>&2 2>&1 1>&3) 5 | case $CHOICE in 6 | yes) 7 | msg_info "Rebooting Server" 8 | sleep 2 9 | msg_ok "Completed Post Install Routines" 10 | reboot 11 | ;; 12 | no) 13 | msg_error "Selected not to Reboot Server (Reboot IS recommended!)" 14 | msg_ok "Completed Post Install Routines" 15 | ;; 16 | esac 17 | } 18 | -------------------------------------------------------------------------------- /Functions/funcDebUpdate: -------------------------------------------------------------------------------- 1 | function update() { # update server 2 | CHOICE=$(whiptail --backtitle "CasaUrsus Debian Scripts" --title "UPDATE" --menu "\nUpdate Server now?" 11 58 2 \ 3 | "yes" " " \ 4 | "no" " " 3>&2 2>&1 1>&3) 5 | case $CHOICE in 6 | yes) 7 | msg_info "Updating Server. Waite until finished! " 8 | apt-get update &>/dev/null # or direct to a log 9 | apt-get -y dist-upgrade &>/dev/null # or direct to a log 10 | msg_ok "Updated Server" 11 | ;; 12 | no) 13 | msg_error "Selected not to Update Server" 14 | ;; 15 | esac 16 | } 17 | -------------------------------------------------------------------------------- /Functions/funcHOSTS: -------------------------------------------------------------------------------- 1 | whiptail --msgbox "$(cat /etc/hosts)" 20 60 2 | -------------------------------------------------------------------------------- /Functions/funcHyrrä: -------------------------------------------------------------------------------- 1 | hyrra() # Function hyrraPyorii. Show a activity spinner 2 | { 3 | pid=$! # PID of the previous running command 4 | x='-\|/' # hyrra in its elements 5 | i=0 6 | while kill -0 $pid 2>/dev/null 7 | do 8 | i=$(( (i+1) %4 )) 9 | printf "\r ${x:$i:1}" 10 | sleep .1 11 | done 12 | printf "\r " 13 | } 14 | -------------------------------------------------------------------------------- /Functions/funcMainAsk: -------------------------------------------------------------------------------- 1 | ## Main section ###################################################################### 2 | clear 3 | header 4 | header_2 5 | echo -e "\nThis script will Perform Routines for a somthing nice to happen.\n" 6 | while true; do 7 | read -p "Start the Install Script [y/n]?" st 8 | case $st in 9 | [Yy]*) break ;; 10 | [Nn]*) clear; exit ;; 11 | *) echo "Please answer yes or no." ;; 12 | esac 13 | done 14 | -------------------------------------------------------------------------------- /Functions/funcSetRoot: -------------------------------------------------------------------------------- 1 | setRoot() { # Function I am root 2 | if [[ "$EUID" = 0 ]]; then 3 | echo -e "\n${okcm} Initialaizing: $pgrm version $ver" # I am root 4 | else 5 | sudo -k 6 | if sudo true; then # Correct password 7 | clear 8 | echo -e "\n${yelb}Start $pgrm version $ver${end}" 9 | echo -e "\n${okcm}Initialaizing...${end}" 10 | else 11 | echo "${redb}wrong password!${end}" 12 | exit #exit if 3 times wrong 13 | fi 14 | fi 15 | } 16 | -------------------------------------------------------------------------------- /Functions/funcSpinner: -------------------------------------------------------------------------------- 1 | function spinner() { # display a animated spinner 2 | # The different Spinner Arrays to choose from 3 | local array1=("◐" "◓" "◑" "◒") 4 | local array2=("░" "▒" "▓" "█") 5 | local array3=("╔" "╗" "╝" "╚") 6 | local array4=("┌" "┐" "┘" "└") 7 | local array5=("▄" "█" "▀" "█") 8 | local array6=('-' '\' '|' '/') # L to R 9 | local array7=('-' '/' '|' '\') # R to L 10 | local array9=("⠋" "⠙" "⠹" "⠸" "⠼" "⠴" "⠦" "⠧" "⠇" "⠏") 11 | local array10=("▏" "▎" "▍" "▌" "▋" "▊" "▉" "█") 12 | local array11=("▁" "▂" "▃" "▄" "▅" "▆" "▇" "█") 13 | 14 | local delays=0.1 # Delay between each characte 15 | 16 | tput civis # Hide cursor and spinn 17 | #echo -e "${yelb} " 18 | while :; do 19 | for character in "${array9[@]}"; do # Use this Array 20 | printf "%s" "$character" 21 | sleep "$delays" 22 | printf "\b" # Move cursor back 23 | done 24 | done 25 | } 26 | -------------------------------------------------------------------------------- /Functions/funcSpinnerRun: -------------------------------------------------------------------------------- 1 | function runSpinner() { 2 | local ONOFF=$1 3 | if [ $ONOFF == 'run' ]; then 4 | # Run the spinner in the background and Save the PID 5 | spinner & 6 | spinner_pid=$! 7 | else 8 | # Terminate the Spinner 9 | kill "$spinner_pid"; wait "$spinner_pid" 2>/dev/null 10 | tput cnorm # Show the Cursor Again 11 | echo -e "${end} " 12 | fi 13 | } 14 | -------------------------------------------------------------------------------- /Functions/funcStopNotRoot: -------------------------------------------------------------------------------- 1 | stoproot(){ # Function Check for root privilidges and exit if not 2 | if [[ "$EUID" != 0 ]]; then 3 | echo -e "\e[0;31mYou need to be root! Pleas run as sudo.\033[0m" # Message in read 4 | exit 5 | fi 6 | } 7 | -------------------------------------------------------------------------------- /Functions/fundDebReposBookworm: -------------------------------------------------------------------------------- 1 | 2 | function sources() { # Select repo sources 3 | # Sources 4 | CHOICE=$(whiptail --backtitle "CasaUrsus Debian Scripts" --title "SOURCES" --menu "The package manager will use the correct sources to update and install packages on your Debian server.\n \nCorrect Debian sources?" 14 58 2 \ 5 | "yes" " " \ 6 | "no" " " 3>&2 2>&1 1>&3) 7 | case $CHOICE in 8 | yes) 9 | msg_info "Correcting Debian Sources" 10 | cat </etc/apt/sources.list 11 | deb http://deb.debian.org/debian bookworm main contrib 12 | deb http://deb.debian.org/debian bookworm-updates main contrib 13 | deb http://security.debian.org/debian-security bookworm-security main contrib 14 | EOF 15 | echo 'APT::Get::Update::SourceListWarnings::NonFreeFirmware "false";' >/etc/apt/apt.conf.d/no-bookworm-firmware.conf 16 | msg_ok "Corrected Debian Sources" 17 | ;; 18 | no) 19 | msg_error "Selected not to Correct Debian Sources" 20 | ;; 21 | esac 22 | } 23 | -------------------------------------------------------------------------------- /Functions/getPool: -------------------------------------------------------------------------------- 1 | function getPool() { # Show basic pool info and Select a Pool 2 | local ST=$1 3 | local LABEL 4 | local TYPE 5 | case $ST in 6 | VM) 7 | LABEL='VM/CT storage' 8 | TYPE=$zfs_st 9 | ;; 10 | ISO) 11 | LABEL='IMG/ISO storage' 12 | TYPE=$img_st 13 | ;; 14 | *) exit ;; 15 | esac 16 | local -a LIST 17 | while read -r line; do 18 | local TAG=$(echo $line | awk '{print $1}') 19 | local TYPE=$(echo $line | awk '{printf "%-10s", $2}') 20 | local FREE=$(echo $line | numfmt --field 4-6 --from-unit=K --to=iec --format %.2f | awk '{printf( "%9sB", $6)}') 21 | local ITEM=" Type: $TYPE Free: $FREE " 22 | local OFFSET=2 23 | if [[ $((${#ITEM} + $OFFSET)) -gt ${LONGA:-} ]]; then 24 | local LONGA=$((${#ITEM} + $OFFSET)) 25 | fi 26 | LIST+=("$TAG" "$ITEM" "OFF") 27 | done < <(echo "$TYPE" | awk 'NR>1') 28 | # Select storage location 29 | if [ $((${#LIST[@]} / 3)) -eq 0 ]; then 30 | echo "${nocm}${red}Unable to detect valid storage location for ISO storage.${end}" >> $logFILE 31 | elif [ $((${#LIST[@]} / 3)) -eq 1 ]; then 32 | printf ${LIST[0]} 33 | else 34 | local POOL 35 | while [ -z "${POOL:+x}" ]; do 36 | POOL=$(whiptail --backtitle "$backTEXT" --title "Select Storage Pool" --radiolist \ 37 | "\nStorage pool to use for the ${LABEL,,}?\nSelect [ Space ] and Accsept [ Enter ]\n" \ 38 | 18 $(($LONGA + 23)) 6 \ 39 | "${LIST[@]}" 3>&1 1>&2 2>&3) || echo "getPool RadioList aborted." >> $logFILE 40 | done 41 | printf $POOL 42 | fi 43 | } 44 | -------------------------------------------------------------------------------- /Functions/header-2: -------------------------------------------------------------------------------- 1 | function header-2() { # print TemplateBuilder. figlet -f standard TemplateBuilder 2 | cat <<"EOF" 3 | _____ _ _ ____ _ _ _ 4 | |_ _|__ _ __ ___ _ __ | | __ _| |_ ___| __ ) _ _(_) | __| | ___ _ __ 5 | | |/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \ _ \| | | | | |/ _` |/ _ \ '__| 6 | | | __/ | | | | | |_) | | (_| | || __/ |_) | |_| | | | (_| | __/ | 7 | |_|\___|_| |_| |_| .__/|_|\__,_|\__\___|____/ \__,_|_|_|\__,_|\___|_| 8 | |_| https://homelab.casaursus.net 9 | EOF 10 | } 11 | -------------------------------------------------------------------------------- /Functions/header-cu1: -------------------------------------------------------------------------------- 1 | function header() { # print CasaUrsus. figlet -f standard CasaUrsus 2 | clear 3 | cat <<"EOF" 4 | 5 | ____ _ _ 6 | / ___|__ _ ___ __ _| | | |_ __ ___ _ _ ___ 7 | | | / _` / __|/ _` | | | | '__/ __| | | / __| 8 | | |__| (_| \__ \ (_| | |_| | | \__ \ |_| \__ \ 9 | \____\__,_|___/\__,_|\___/|_| |___/\__,_|___/ 10 | EOF 11 | } 12 | -------------------------------------------------------------------------------- /Functions/sectionBreakes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # # 3 | # 👍 👍 E D I T t h i s S E C T I O N 👍 👍 # 4 | # # 5 | ############################################################################### 6 | 7 | #------------------------------------------------------------------------------ 8 | # E n d o f t h e E d i t a b l e S e c t i o n # 9 | #----------------------------------------------------------------------------- 10 | 11 | ############################################################################### 12 | # # 13 | # ✋ N O n e e d t o E D I T B e l o w t h i s P o i n t 🚫 # 14 | # # 15 | ############################################################################### 16 | 17 | ############################################################################### 18 | # # 19 | # 🧱🧱🧱🧱🧱🧱 C R E A T E t h e N O D E S 🧱🧱🧱🧱🧱🧱 # 20 | # # 21 | ############################################################################### 22 | 23 | ############################################################################### 24 | # # 25 | # 🧱🧱🧱🧱🧱🧱 E X E C U T I O N A B L E C O D E 🧱🧱🧱🧱🧱🧱 # 26 | # # 27 | ############################################################################### 28 | 29 | # Code Section ===============================================================# 30 | 31 | # Initialization menu --------------------------------------------------------# 32 | 33 | # End of Code Section and Initialization Menu ================================# 34 | 35 | 36 | 37 | # End of Script ############################################################### 38 | -------------------------------------------------------------------------------- /Functions/setLAN: -------------------------------------------------------------------------------- 1 | function setLAN(){ 2 | # Set the Virtual Bridge 3 | vmbr=$(whiptail --backtitle "$backTEXT" --title "VLAN Dialog" --inputbox \ 4 | "\nVirtual Bridge to be useed" \ 5 | 10 48 vmbr2 3>&1 1>&2 2>&3) 6 | echo "${cyn} - Bridge: $vmbr" >> $logFILE 7 | # Use a Virtual LAN 8 | if whiptail --backtitle "$backTEXT" --title "VLAN Dialog" --yesno \ 9 | "\nDo you need to use a VLAN?" 10 48; then 10 | vlan=$(whiptail --backtitle "$backTEXT" --title "VLAN Dialog" --inputbox\ 11 | "\nVLAN to use for the VM/Template" 10 48 10 3>&1 1>&2 2>&3) 12 | echo "${cyn} - VLAN: $vlan" >> $logFILE 13 | else 14 | vlan=0 15 | echo "${cyn} - User selected NOT to use a VLAN" >> $logFILE 16 | fi 17 | } 18 | -------------------------------------------------------------------------------- /Functions/setOptions: -------------------------------------------------------------------------------- 1 | function setOPTIONS() { 2 | 3 | OPTION_MENU=() 4 | LONGA=0 5 | while read -r ONOFF TAG ITEM; do 6 | OFFSET=2 7 | ((${#ITEM} + OFFSET > LONGA)) && LONGA=${#ITEM}+OFFSET 8 | OPTION_MENU+=("$TAG" "$ITEM " "$ONOFF") 9 | done < <( 10 | cat <&1 1>&2 2>&3 | tr -d '"') || exit 31 | [ -z "$OPTIONS" ] && { 32 | whiptail --backtitle "$backTEXT" --title "No Options Selected" --msgbox "It appears that no Options was selected" 10 68 33 | } 34 | 35 | if [ -z "$OPTIONS" ]; then 36 | echo "${red}⚠ No option was selected (user hit Cancel or unselected all options)${end}" >> $logFILE 37 | else 38 | echo "${cynb} - User selected options:${end}" >> $logFILE 39 | for CHOICE in $OPTIONS; do 40 | case "$CHOICE" in 41 | "Qemu-Guest-Agent") 42 | o1="y" 43 | echo "${cyn} - qemu-guest-agent${end}" >> $logFILE 44 | ;; 45 | "nano") 46 | o2="y" 47 | echo "${cyn} - nano editor, ncurses-term${end}" >> $logFILE 48 | ;; 49 | "git") 50 | o3="y" 51 | echo "${cyn} - git${end}" >> $logFILE 52 | ;; 53 | "nala") 54 | o21="y" 55 | echo "${cyn} - nala${end}" >> $logFILE 56 | ;; 57 | "unattended-upgrades") 58 | o4="y" 59 | echo "${cyn} - unattended-upgrades${end}" >> $logFILE 60 | ;; 61 | "Fail2Ban") 62 | o5="y" 63 | echo "${cyn} - fail2ban${end}" >> $logFILE 64 | ;; 65 | "clamav") 66 | o6="y" 67 | echo "${cyn} - clamav-daemon${end}" >> $logFILE 68 | ;; 69 | "mailutils") 70 | o7="y" 71 | echo "${cyn} - mailutils${end}" >> $logFILE 72 | ;; 73 | "Docker-CE") 74 | o10="y" 75 | echo "${cyn} - Docker-CE${end}" >> $logFILE 76 | ;; 77 | "Dockge") 78 | o20="y" 79 | ;; 80 | "Portainer-CE") 81 | o11="y" 82 | echo "${cyn} - Portainer-CE${end}" >> $logFILE 83 | ;; 84 | "Agent") 85 | o12="y" 86 | echo "${cyn} - Portainer Agent${end}" >> $logFILE 87 | ;; 88 | "Docker") 89 | o13="y" 90 | echo "${cyn} - Docker-EE \$\$\$${end}" >> $logFILE 91 | ;; 92 | "Portainer-BE") 93 | o14="y" 94 | echo "${cyn} - Portainer \$\$\$${end}" >> $logFILE 95 | ;; 96 | "K3s") 97 | o8="y" 98 | echo "${cyn} - make a K3s cluster${end}" >> $logFILE 99 | ;; 100 | "K8s") 101 | o9="y" 102 | echo "${cyn} - make a K8s cluster${end}" >> $logFILE 103 | ;; 104 | *) 105 | echo "${red}⚠ Unsupported item $CHOICE! ${end}" >> $logFILE 106 | exit 1 107 | ;; 108 | esac 109 | done 110 | fi 111 | } 112 | -------------------------------------------------------------------------------- /Functions/setUser: -------------------------------------------------------------------------------- 1 | function setUSER() { 2 | # Set Cloid-init user 3 | ciu=$(whiptail --backtitle "$backTEXT" --title "Create CI User" --inputbox \ 4 | "\nCreate with CI user" \ 5 | 10 48 $admin 3>&1 1>&2 2>&3) 6 | echo "${cyn} - Cloud-init user: $ciu" >> $logFILE 7 | 8 | # Create a long and complicated password 6 is a joke 8 is something 12 is semi ok 16 is ok 20 is good 9 | while [[ "$cip" != "$cip_repeat" || ${#cip} -lt $passl ]]; do 10 | cip=$(whiptail --backtitle "$backTEXT" --title "Create CI User" --passwordbox \ 11 | "\n${cip_invalid}Please enter a password (6 chars min.): " 10 48 $passwd 3>&1 1>&2 2>&3) 12 | cip_repeat=$(whiptail --backtitle "$backTEXT" --title "Create CI User" --passwordbox \ 13 | "\nPlease repeat the password: " 10 48 $passwd 3>&1 1>&2 2>&3) 14 | cip_invalid="WARNING Password too short, or not matching! " 15 | done 16 | # Shoud NOT be used for production 17 | if showPASSWD=true; then 18 | echo "${cyn} - Cloud-init password: $cip" >> $logFILE 19 | else 20 | echo "${cyn} - Cloud-init password: /" >> $logFILE 21 | fi 22 | #PASSWORD="$(openssl rand -base64 16)" 23 | 24 | #read -rp " - set key from ~/.ssh/my_key [y/N] : " my_key 25 | # Set Key name and address 26 | my_key=$(whiptail --backtitle "$backTEXT" --title "Create CI User" --inputbox \ 27 | "\nUsers SSH Public Key is: $my_key" \ 28 | 10 48 $initKEY 3>&1 1>&2 2>&3) 29 | echo "${cyn} - My key: $my_key" >> $logFILE 30 | 31 | } 32 | -------------------------------------------------------------------------------- /Functions/shebang: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Standard Unix Shebang 3 | 4 | # Copyright (c) 2020-2024 casaursus 5 | # Author: nallej (casaursus) 6 | # License: MIT 7 | # https://github.com/nallej/Scripts/raw/main/LICENSE 8 | 9 | # Variables and functions ===================================================== 10 | 11 | ## Standard Error handling settings for a script ----------------------------## 12 | # This is making the script more robust by using: # 13 | # set -euo pipefail # 14 | # -e: Exit immediately if a command exits with a non-zero status # 15 | # Ensuring fast fail on errors (set -e) # 16 | # -u: Treat unset variables as an error and exit immediately # 17 | # Avoiding the use of unset variables # 18 | # -o pipefail: Return exit status of last command in pipeline that failed # 19 | # Ensuring pipelines fail if any command within them fails # 20 | # shopt -s inherit_errexit nullglob # 21 | # - inherit_errexit: If set, the -e option will be inherited in # 22 | # shell functions and command substitutions # 23 | # - nullglob: If set, bash allows filename patterns that match # 24 | # - no files to expand to a null string, rather than themselves # 25 | # Preventing non-matching globs from causing issues by # 26 | # expanding to a null string # 27 | set -euo pipefail # 28 | shopt -s inherit_errexit nullglob # 29 | ##---------------------------------------------------------------------------## 30 | 31 | ## Placeholders for messages: OK, Error, Info --------## 32 | function msg_info() { # Just a info-msg # 33 | local msg="$1" # 34 | echo -ne " ${DASH} ${YEL}${msg}..." # 35 | } # 36 | function msg_ok() { # OK msg # 37 | local msg="$1" # 38 | echo -e "${CCL} ${OKCM} ${GRE}${msg}${ENDC}" # 39 | } # 40 | function msg_error() { # Error-msg # 41 | local msg="$1" # 42 | echo -e "${CCL} ${NOCM} ${RED}${msg}${ENDC}" # 43 | } # 44 | ##----------------------------------------------------## 45 | -------------------------------------------------------------------------------- /Functions/version: -------------------------------------------------------------------------------- 1 | version="myTempBuilder.sh is part of the My HomeLab Journey Project 2 | - https://homelab.casaursus.net 3 | - https://homelab.casaursus.net/proxmox-automation 4 | - https://homelab.casaursus.net/setting-up-kubernetes-k8s 5 | 6 | Version History: 7 | - v1.0 29.11.2022 v1.1 01.12.2022 8 | - v2.0 04.01.2023 v2.1 09.01.2023 v2.2 29.01.2023 9 | - v3.0 30.05.2023 v3.1 31.05.2023 v3.2 01.06.2023 v3.3 12.10.2023 10 | - v4.0 12.10.2023 v4.1 31.10.2023 11 | - v5.0 30.11.2023" 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 NalleJ 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MyJourney 2 | To host the Docker Compose files for the blog on https://homelab.casaursus.net 3 | 4 | ## Newest scripts 5 | My newest scripts will be found in the **SCRIPTS** section 6 | - My new Template builder script can be or pulled by git or downloaded from
7 | https://github.com/nallej/MyJourney/raw/main/scripts/myTemplateBuilder.sh?ref=homelab.casaursus.net 8 | - It automate template creation for VMs and K0s, K3s and K8s clusters 9 | - New version 5.2 10 | https://github.com/nallej/MyJourney/raw/main/scripts/TemplateBuilder.sh 11 | 12 | 13 | ### Other scripts 14 | New setup script myVMsetup is recommended over the 3 part scripts. 15 | Get it to your VM pull:
`wget https://github.com/nallej/MyJourney/raw/main/myVMsetup.sh` 16 | 17 | Make the script executable : `chmod +x myVMsetup.sh` 18 | 19 | Obsolete version 20 | Initial pull: `wget https://raw.githubusercontent.com/nallej/MyJourney/main/1-install.sh` 21 | 22 | Make the script executable : `chmod +x 1-install.sh` 23 | 24 | ## Other 25 | Clear an old key :
`ssh-keygen -f "/etc/ssh/ssh_known_hosts" -R "10.10.10.10"` 26 | Generate a new key :
`ssh-keygen -t ed25519 -C "user@example.com"`
save as filneme -f filename 27 | Add your public key :
`ssh-copy-id -i ~/.ssh/id_ed25519.pub user@10.10.10.10`
28 | 29 | Fix node ssh key issue:
`ssh -o "HostKeyAlias=node103" root@10.10.10.103`
30 | 31 | Updat Proxmox bash with my preferenses:
`wget https://github.com/nallej/MyJourney/raw/main/BashAddon.sh`
32 | 33 | Add to or change the bash commands:
`wget https://github.com/nallej/MyJourney/raw/main/.bash_aliases`
34 | And also the personal bash prompt:
`wget https://github.com/nallej/MyJourney/raw/main/.bash_prompt` 35 | 36 | ## No Nag 37 | sed -Ezi.bak "s/(function\(orig_cmd\) \{)/\1\n\torig_cmd\(\);\n\treturn;/g" /usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js && systemctl restart pveproxy.service 38 | 39 | ## Firewall errors 40 | Firewall errors can be really bad. 41 | To fix do `pve-firewall stop` 42 | If you like to disable it permanently 43 | - `nano /etc/pve/firewall/cluster.fw` 44 | - set `enable: 1` to `enable: 0` 45 | # 46 |
Proxmox® is a registered trademark of Proxmox Server Solutions GmbH.
47 | -------------------------------------------------------------------------------- /StopDelCorosync.sh: -------------------------------------------------------------------------------- 1 | # Stop the corosync and the pve-cluster services on the node: 2 | # wget https://github.com/nallej/MyJourney/raw/main/StopDelCorosync.sh 3 | 4 | systemctl stop pve-cluster 5 | systemctl stop corosync 6 | 7 | # Start the cluster filesystem again in local mode: 8 | pmxcfs -l 9 | 10 | # Delete the corosync configuration files: 11 | rm /etc/pve/corosync.conf 12 | rm -r /etc/corosync/* 13 | 14 | # Start the filesystem again as normal service: 15 | 16 | killall pmxcfs 17 | systemctl start pve-cluster 18 | 19 | # Remove any left over .conf files 20 | echo "" 21 | echo "" 22 | echo "Remove any *.conf left in /etc/pve/qemu-server" 23 | echo "Remove any *.conf left in /etc/pve/lxc" 24 | echo "Remove any *.conf left in /etc/pve/nodes//qemu-server" 25 | echo "Remove any *.conf left in /etc/pve/nodes//lxc" 26 | echo "" 27 | # 28 | # Browser errors 29 | # You can maybe fix it by: 30 | # rm remove /etc/pve/priv/pve-root-ca.key /etc/pve/pve-root-ca.pem 31 | # rm /etc/pve/local/pve-ssl.pem /etc/pve/local/pve-ssl.key /etc/pve/local/pveproxy-ssl.pem /etc/pve/local/pveproxy-ssl.key (on each node!) 32 | # run pvecm updatecerts 33 | # run systemctl restart pveproxy 34 | # 35 | # Now the GUI should work again, with the default self-signed certificates. 36 | # In the GUI or 'pvenode' upload your certificate + key 37 | # (it will be stored in '/etc/pve/local/pveproxy-ssl.pem' / '/etc/pve/local/pveproxy-ssl.key' 38 | -------------------------------------------------------------------------------- /WOL.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #-----------------------------------------------------------------------------# 4 | # WOL.sh for Proxmox Servers # 5 | # Part of the MyJourney project @ homelab.casaursus.net # 6 | # # 7 | # V.1 Created by Nalle Juslén 29.8.2022 # 8 | # -review 1.12.2022 # 9 | # # 10 | # V.2 Created by Nalle Juslén 4.1.2023 # 11 | # - revison 9.3.2023, 29.8.2023 # 12 | # # 13 | # How to use this tool: Enter myNIC and Servers MAC abd URL below and run. # # 14 | # # 15 | #-----------------------------------------------------------------------------# 16 | 17 | 18 | # Please enter the Servers MAC and URL here ==================================# 19 | # Function to set URL and MAc for the Servers --------------------------------# 20 | setMACurl () { 21 | # Node-1 22 | MAC1=00:11:22:33:44:55 23 | URL1=192.0.2.41 24 | # Node-2 25 | MAC2=00:11:22:33:44:55 26 | URL2=192.0.2.42 27 | # Node-3 28 | MAC3=00:11:22:33:44:55 29 | URL3=192.0.2.43 30 | # Node-4 31 | MAC4=00:11:22:33:44:55 32 | URL4=192.0.2.44 33 | # Node-5 34 | MAC5=00:11:22:33:44:55 35 | URL5=192.0.2.45 36 | # Node-6 37 | MAC6=00:11:22:33:44:55 38 | URL6=192.0.2.6 39 | # Node-7 40 | MAC7=00:11:22:33:44:55 41 | URL7=192.0.2.47 42 | # Node-8 43 | MAC8=00:11:22:33:44:55 44 | URL8=192.0.2.48 45 | # Node-9 46 | MAC9=00:11:22:33:44:55 47 | URL9=10.10.10.49 48 | } 49 | # ============================================================================# 50 | 51 | # My myNIC used by etherwake =================================================# 52 | myNIC=enp2s0 53 | #=============================================================================# 54 | 55 | # Function to display an animated spinner ------------------------------------# 56 | spinner() { 57 | #The different Spinner Arrays to choose from 58 | local array1=("◐" "◓" "◑" "◒") 59 | local array2=("░" "▒" "▓" "█") 60 | local array3=("╔" "╗" "╝" "╚") 61 | local array4=("┌" "┐" "┘" "└") 62 | local array5=("▄" "█" "▀" "█") 63 | local array6=("⠋" "⠙" "⠹" "⠸" "⠼" "⠴" "⠦" "⠧" "⠇" "⠏") 64 | # Delay between each character 65 | local delays=0.1 66 | 67 | while :; do 68 | for character in "${array6[@]}"; do #Which Array to Use 69 | printf "%s" "$character" 70 | sleep "$delays" 71 | printf "\b" # Move the cursor back 72 | done 73 | done 74 | } 75 | 76 | # Function to test if a Server is down, using ping ----------------------------# 77 | testPing () { 78 | RETRYCOUNT=1; 79 | #echo Checking server: $1 80 | ping -c $RETRYCOUNT $1 > /dev/null 2>&1 81 | if [ $? -ne 0 ] 82 | then 83 | status=1 84 | #echo $1 down 85 | else 86 | status=2 87 | #echo $1 live 88 | fi 89 | return $status 90 | } 91 | 92 | # Function check running servers ---------------------------------------------# 93 | runningServers() { 94 | 95 | 96 | testPing $URL1; st1=$?; if [[ $st1 == 2 ]]; then 97 | echo -e "\b Node-1 is ${G}running${No}"; else echo -e "\b Node-1 is ${R}off line${No}"; fi 98 | testPing $URL2; st2=$?; if [[ $st2 == 2 ]]; then 99 | echo -e "\b Node-2 is ${G}running${No}"; else echo -e "\b Node-2 is ${R}off line${No}"; fi 100 | testPing $URL3; st3=$?; if [[ $st3 == 2 ]]; then 101 | echo -e "\b Node-3 is ${G}running${No}"; else echo -e "\b Node-3 is ${R}off line${No}"; fi 102 | testPing $URL4; st4=$?; if [[ $st4 == 2 ]]; then 103 | echo -e "\b Node-4 is ${G}running${No}"; else echo -e "\b Node-4 is ${R}off line${No}"; fi 104 | testPing $URL5; st5=$?; if [[ $st5 == 2 ]]; then 105 | echo -e "\b Node-5 is ${G}running${No}"; else echo -e "\b Node-5 is ${R}off line${No}"; fi 106 | testPing $URL6; st6=$?; if [[ $st6 == 2 ]]; then 107 | echo -e "\b Node-6 is ${G}running${No}"; else echo -e "\b Node-6 is ${R}off line${No}"; fi 108 | testPing $URL7; st7=$?; if [[ $st7 == 2 ]]; then 109 | echo -e "\b Node-7 is ${G}running${No}"; else echo -e "\b Node-7 is ${R}off line${No}"; fi 110 | testPing $URL8; st8=$?; if [[ $st8 == 2 ]]; then 111 | echo -e "\b Node-8 is ${G}running${No}"; else echo -e "\b Node-8 is ${R}off line${No}"; fi 112 | testPing $URL9; st9=$?; if [[ $st9 == 2 ]]; then 113 | echo -e "\b Node-9 is ${G}running${No}"; else echo -e "\b Node-9 is ${R}off line${No}"; fi 114 | echo "" 115 | } 116 | 117 | # Colors and Controls to use -------------------------------------------------# 118 | R='\e[0;31m' 119 | G='\e[0;32m' 120 | Y='\e[1;33m' 121 | No='\033[0m' # No Color 122 | 123 | # Main =======================================================================# 124 | 125 | clear 126 | tput setaf 3 127 | 128 | echo "Start Proxmox nodes" 129 | 130 | # Check for root privilidges 131 | #if [[ "$EUID" != 0 ]]; then 132 | # echo "${R}You need to be root. Pleas run as sudo.${No}" 133 | # exit 134 | #fi 135 | 136 | if [[ "$EUID" = 0 ]]; then 137 | echo "" #Start Proxmox nodes" 138 | echo "Initialaizing:" #"already root" 139 | else 140 | sudo -k 141 | if sudo true; then 142 | clear 143 | echo "Start Proxmox nodes" 144 | echo "" 145 | echo "Initialaizing:" #correct password 146 | else 147 | echo "wrong password" 148 | exit #exit 1 #re-try the password 149 | fi 150 | fi 151 | 152 | sleep 1 153 | #echo "Initialaizing..." 154 | setMACurl 155 | tput setaf 3 156 | echo -e "\b Server Status" 157 | #echo "" 158 | tput sgr0 159 | echo -e " \e[4mnode status \e[0m" 160 | 161 | # Run the spinner in the background and Save the PID 162 | spinner & 163 | spinner_pid=$! 164 | 165 | runningServers 166 | 167 | # Terminate the Spinner 168 | kill "$spinner_pid" 169 | wait "$spinner_pid" 2>/dev/null 170 | # Show the Cursor Again 171 | tput cnorm 172 | 173 | read -rp "Do you like to continue [Yn]: " cont 174 | if [[ $cont == [nN] ]]; then exit; fi 175 | 176 | tput setaf 3 177 | echo -e "\e[4m${Y}Start Servers not running\e[0m" 178 | #echo "" 179 | #tput sgr0 180 | 181 | # Ask to start if not running 182 | if [[ $st1 == 2 ]]; then 183 | echo -e " Node-1 is ${G}running${No} $URL1 $MAC1 $st" 184 | else 185 | read -rp " Node-1 [y/N] : $st" p1 186 | fi 187 | 188 | if [[ $st2 == 2 ]]; then 189 | echo -e " Node-2 is ${G}running${No} $URL2 $MAC2" 190 | else 191 | read -rp " Node-2 [y/N] : " p2 192 | fi 193 | 194 | if [[ $st3 == 2 ]]; then 195 | echo -e " Node-3 is ${G}running${No} $URL3 $MAC3" 196 | else 197 | read -rp " Node-3 [y/N] : " p3 198 | fi 199 | 200 | if [[ $st4 == 2 ]]; then 201 | echo -e " Node-4 is ${G}running${No} $URL4 $MAC4" 202 | else 203 | read -rp " Node-4 [y/N] : " p4 204 | fi 205 | 206 | if [[ $st5 == 2 ]]; then 207 | echo -e " Node-5 is ${G}running${No} $URL5 $MAC5" 208 | else 209 | read -rp " Node-5 [y/N] : " p5 210 | fi 211 | 212 | if [[ $st6 == 2 ]]; then 213 | echo -e " Node-6 is ${G}running${No} $URL6 $MAC6" 214 | else 215 | read -rp " Node-6 [y/N] : " p6 216 | fi 217 | 218 | if [[ $st7 == 2 ]]; then 219 | echo -e " Node-7 is ${G}running${No} $URL7 $MAC7" 220 | else 221 | read -rp " Node-7 [y/N] : " p7 222 | fi 223 | 224 | if [[ $st8 == 2 ]]; then 225 | echo -e " Node-8 is ${G}running${No} $URL8 $MAC8" 226 | else 227 | read -rp " Node-8 [y/N] : " p8 228 | fi 229 | 230 | if [[ $st9 == 2 ]]; then 231 | echo -e " Node-9 is ${G}running${No} $URL9 $MAC9" 232 | else 233 | read -rp " Node-9 [y/N] : " p9 234 | fi 235 | echo "" 236 | read -rp $'\e[1;31mStart the Servers [y/N] : \e[0m' ok 237 | echo "" 238 | 239 | # Start the choosen nodes ----------------------------------------------------# 240 | if [[ $ok == [yY] ]]; then 241 | # Start the nodes (need to run as sudo) 242 | if [[ $p1 == [yY] ]]; then echo "Starting Node-1"; etherwake $MAC1 -i $myNIC; sleep .5; fi 243 | if [[ $p2 == [yY] ]]; then echo "Starting Node-2"; etherwake $MAC2 -i $myNIC; sleep .5; fi 244 | if [[ $p3 == [yY] ]]; then echo "Starting Node-3"; etherwake $MAC3 -i $myNIC; sleep .5; fi 245 | if [[ $p4 == [yY] ]]; then echo "Starting Node-4"; etherwake $MAC4 -i $myNIC; sleep .5; fi 246 | if [[ $p5 == [yY] ]]; then echo "Starting Node-5"; etherwake $MAC5 -i $myNIC; sleep .5; fi 247 | if [[ $p6 == [yY] ]]; then echo "Starting Node-6"; etherwake $MAC6 -i $myNIC; sleep .5; fi 248 | if [[ $p7 == [yY] ]]; then echo "Starting Node-7"; etherwake $MAC7 -i $myNIC; sleep .5; fi 249 | if [[ $p8 == [yY] ]]; then echo "Starting Node-8"; etherwake $MAC8 -i $myNIC; sleep .5; fi 250 | if [[ $p9 == [yY] ]]; then echo "Starting Node-9"; etherwake $MAC9 -i $myNIC; sleep .5; fi 251 | echo "" 252 | fi 253 | 254 | # End of script ==============================================================# 255 | -------------------------------------------------------------------------------- /add-a-app/main.function: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /deltest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # deltest.sh 1.1 3 | 4 | qm destroy 8000 --destroy-unreferenced-disks 1 --purge 1 --skiplock 0 5 | qm destroy 9000 --destroy-unreferenced-disks 1 --purge 1 --skiplock 0 6 | qm destroy 5000 --destroy-unreferenced-disks 1 --purge 1 --skiplock 0 7 | qm destroy 5001 --destroy-unreferenced-disks 1 --purge 1 --skiplock 0 8 | qm destroy 5002 --destroy-unreferenced-disks 1 --purge 1 --skiplock 0 9 | qm destroy 5003 --destroy-unreferenced-disks 1 --purge 1 --skiplock 0 10 | -------------------------------------------------------------------------------- /dns/config/db.192.168.1: -------------------------------------------------------------------------------- 1 | ; Create a reverse lookup zone 2 | 3 | $TTL 2d 4 | 5 | @ IN SOA ns1.lab.example.com. admin.example.com ( 6 | 2023011200 ; serial number 7 | 12h ; refresh 8 | 15m ; retry 9 | 3w ; expire 10 | 2h ; minimum ttl 11 | ) 12 | 13 | @ IN NS ns1.lab.example.com. 14 | 15 | ; -- add reverse dns records below 16 | 17 | 3 IN PTR ns1.lab.example.com. 18 | 41 IN PTR pve1.lab.example.com. 19 | 42 IN PTR pve2.lab.example.com. 20 | 43 IN PTR pve3.lab.example.com. 21 | 44 IN PTR pve4.lab.example.com. 22 | 45 IN PTR pve5.lab.example.com. 23 | 46 IN PTR pve6.lab.example.com. 24 | 49 IN PTR pbs.lab.example.com. 25 | 50 IN PTR nas.lab.example.com. 26 | 27 | ; -- lab servers for testing ar in the db.10.10.20 file 28 | -------------------------------------------------------------------------------- /dns/config/db.lab-example.com.zone: -------------------------------------------------------------------------------- 1 | ; Create a forward lookup zone 2 | ; forward zone for example.com 3 | ; 4 | $TTL 2d ; default TTL for zone 5 | 6 | $ORIGIN lab.example.com. 7 | 8 | ; Start of Authority RR defining the key characteristics of the zone (domain) 9 | @ IN SOA ns1.lab.example.com. admin.example.com ( 10 | 2023011200 ; serial 11 | 12h ; refresh 12 | 15m ; retry 13 | 3w ; expire 14 | 2h ; minimum ttl 15 | ) 16 | 17 | @ IN NS ns1.lab.example.com. 18 | 19 | ns1 IN A 192.168.1.3 20 | 21 | ; A records 22 | ; -- add the production dns records below 23 | ns1 IN A 192.168.1.3 24 | pve1 IN A 192.168.1.41 25 | pve2 IN A 192.168.1.42 26 | pve3 IN A 192.168.1.43 27 | pve4 IN A 192.168.1.44 28 | pve5 IN A 192.168.1.45 29 | pve6 IN A 192.168.1.46 30 | pbs IN A 192.168.1.49 31 | nas IN A 192.168.1.50 32 | 33 | ; -- Infra switches, routers ntp-servers ... 34 | 35 | 36 | ; -- lab servers for testing and play 37 | srv-nas-1 IN A 10.10.20.50 38 | srv-ubuntu-2 IN A 10.10.20.54 39 | *.srv-ubuntu-2 IN A 10.10.20.54 40 | srv-nas-2 IN A 10.10.20.55 41 | 42 | ; AAAA records if using ipv6 43 | 44 | ; CNAME records, aliases ftp (ftp server) to an external domain 45 | ftp IN CNAME ftp.example.net. 46 | 47 | ; TXT records -------------------------------------------------------------------------------- /dns/config/named.conf: -------------------------------------------------------------------------------- 1 | acl internal { 2 | 10.10.10.0/24; 3 | 10.10.20.0/24; 4 | 10.10.30.0/24; 5 | 10.10.40.0/24; 6 | 10.10.50.0/24; 7 | 10.10.60.0/24; 8 | 10.10.70.0/24; 9 | 10.10.80.0/24; 10 | 10.10.90.0/24; 11 | 10.20.0.0/16; 12 | 10.50.0.0/16; 13 | 192.168.1.0/24; 14 | }; 15 | 16 | options { 17 | forwarders { 18 | 192.168.1.5; 19 | 1.1.1.1; 20 | 1.0.0.1; 21 | }; 22 | recursion yes; 23 | allow-recursion { 127.0.0.1; 192.168.1.0/24; }; 24 | allow-query { internal; }; 25 | allow-query-cache { internal; }; 26 | allow-recursion { internal; }; 27 | 28 | dnssec-validation no; 29 | 30 | listen-on-v6 port 53 { ::1; }; 31 | listen-on port 53 { 127.0.0.1; 192.168.1.3; }; 32 | 33 | }; 34 | 35 | zone "lab.example.com" IN { 36 | type master; 37 | file "/etc/bind/db.lab-excample-com.zone"; 38 | }; 39 | 40 | 41 | zone "1.168.192.in-addr.arpa" { 42 | type master; 43 | file "/etc/bind/db.192.168.1"; 44 | }; -------------------------------------------------------------------------------- /dns/dhcp/data/dhcpd.conf: -------------------------------------------------------------------------------- 1 | # Global settings 2 | 3 | ddns-update-style none; 4 | 5 | log-facility local7; 6 | 7 | default-lease-time 600; 8 | max-lease-time 7200; 9 | 10 | # Server is authoritative i.e. the only DHCP server 11 | authoritative; 12 | 13 | # Local subnet for network topology 14 | subnet 192.168.1.0 netmask 255.255.255.0 { 15 | option routers 192.168.1.1; 16 | option subnet-mask 255.255.255.0; 17 | option broadcast-address 192.168.1.255; 18 | option domain-name-servers 192.168.1.3, 192.168.1.5; 19 | option ntp-servers 192.168.1.1; 20 | option domain-name "lab.example.com"; 21 | 22 | default-lease-time 43200; 23 | max-lease-time 86400; 24 | 25 | range 192.168.1.100 192.168.1.199; 26 | 27 | # Reserved IP address for specific hosts ie. fixed IP 28 | 29 | host pve1 { 30 | hardware ethernet AA:BB:CC:E5:E6:E7; 31 | fixed-address 192.168.1.41; 32 | } 33 | host pve2 { 34 | hardware ethernet CC:DD:EE:28:F6:45; 35 | fixed-address 192.168.1.42; 36 | } 37 | 38 | } 39 | 40 | # Next subnet starts here -------------------------------------------------------------------------------- /dns/dhcp/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | # 4 | # Your DNS stuff here 5 | # 6 | dhcp: 7 | image: networkboot/dhcpd 8 | container_name: dhcpd 9 | volumes: 10 | - ./dhcp/data:/data 11 | network_mode: "host" 12 | restart: unless-stopped 13 | # Using port 67/udp -------------------------------------------------------------------------------- /dns/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3" 2 | 3 | services: 4 | bind9: 5 | container_name: bind9-ns1 6 | image: ubuntu/bind9:latest 7 | environment: 8 | - BIND9_USER=root 9 | - TZ=Europe/Helsinki 10 | ports: 11 | - "53:53/tcp" 12 | - "53:53/udp" 13 | volumes: 14 | - ./config:/etc/bind 15 | - ./cache:/var/cache/bind 16 | - ./records:/var/lib/bind 17 | restart: unless-stopped 18 | ## Add DHCP here -------------------------------------------------------------------------------- /dozzle/docker-compose.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: '3' 3 | # Log reader, deploy from Portainer or by hand 4 | services: 5 | dozzle: 6 | container_name: dozzle 7 | image: amir20/dozzle:latest 8 | volumes: 9 | - /var/run/docker.sock:/var/run/docker.sock 10 | ports: 11 | - 9999:8080 12 | restart: unless-stopped 13 | networks: 14 | - pihalla 15 | # networks to be used by service 16 | networks: 17 | pihalla: 18 | external: true 19 | ... 20 | -------------------------------------------------------------------------------- /heimdall/docker-compose.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: '3' 3 | # a dashboard with status indications 4 | services: 5 | heimdall: 6 | image: lscr.io/linuxserver/heimdall 7 | container_name: heimdall 8 | #configur your environment 9 | environment: 10 | - PUID=1000 11 | - PGID=100 12 | - TZ=Europe/Helsinki 13 | volumes: 14 | - ./config:/config 15 | # use your port numbers if using direct access 16 | ports: 17 | - 9080:80 18 | - 9088:443 19 | restart: unless-stopped 20 | # insert your internal network for reverse proxy use 21 | networks: 22 | - kadulla 23 | # networks to be used by service 24 | networks: 25 | kadulla: 26 | external: true 27 | ... 28 | -------------------------------------------------------------------------------- /interface/authelia-cfg-auth: -------------------------------------------------------------------------------- 1 | location / { 2 | set $upstream_authelia http://192.168.###.###:9091; # http:// e.g. http://192.168.1.3:9091 3 | proxy_pass $upstream_authelia; 4 | client_body_buffer_size 128k; 5 | 6 | #Timeout if the real server is dead 7 | proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; 8 | 9 | # Advanced Proxy Config 10 | send_timeout 5m; 11 | proxy_read_timeout 360; 12 | proxy_send_timeout 360; 13 | proxy_connect_timeout 360; 14 | 15 | # Basic Proxy Config 16 | proxy_set_header Host $host; 17 | proxy_set_header X-Real-IP $remote_addr; 18 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 19 | proxy_set_header X-Forwarded-Proto $scheme; 20 | proxy_set_header X-Forwarded-Host $http_host; 21 | proxy_set_header X-Forwarded-Uri $request_uri; 22 | proxy_set_header X-Forwarded-Ssl on; 23 | proxy_redirect http:// $scheme://; 24 | proxy_http_version 1.1; 25 | proxy_set_header Connection ""; 26 | proxy_cache_bypass $cookie_session; 27 | proxy_no_cache $cookie_session; 28 | proxy_buffers 64 256k; 29 | 30 | # If behind reverse proxy, forwards the correct IP 31 | set_real_ip_from 10.0.0.0/8; 32 | set_real_ip_from 172.0.0.0/8; 33 | set_real_ip_from 192.168.0.0/16; 34 | set_real_ip_from fc00::/7; 35 | real_ip_header X-Forwarded-For; 36 | real_ip_recursive on; 37 | } 38 | -------------------------------------------------------------------------------- /interface/authelia-cfg-site: -------------------------------------------------------------------------------- 1 | location /authelia { 2 | internal; 3 | #set $upstream_authelia http:///api/verify; #ADD YOUR IP AND PORT OF AUTHELIA - same for all your sites 4 | set $upstream_authelia http://192.168.1.101:9091/api/verify; 5 | proxy_pass_request_body off; 6 | proxy_pass $upstream_authelia; 7 | proxy_set_header Content-Length ""; 8 | 9 | # Timeout if the real server is dead 10 | proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; 11 | client_body_buffer_size 128k; 12 | proxy_set_header Host $host; 13 | proxy_set_header X-Original-URL $scheme://$http_host$request_uri; 14 | proxy_set_header X-Real-IP $remote_addr; 15 | proxy_set_header X-Forwarded-For $remote_addr; 16 | proxy_set_header X-Forwarded-Proto $scheme; 17 | proxy_set_header X-Forwarded-Host $http_host; 18 | proxy_set_header X-Forwarded-Uri $request_uri; 19 | proxy_set_header X-Forwarded-Ssl on; 20 | proxy_redirect http:// $scheme://; 21 | proxy_http_version 1.1; 22 | proxy_set_header Connection ""; 23 | proxy_cache_bypass $cookie_session; 24 | proxy_no_cache $cookie_session; 25 | proxy_buffers 4 32k; 26 | 27 | send_timeout 5m; 28 | proxy_read_timeout 240; 29 | proxy_send_timeout 240; 30 | proxy_connect_timeout 240; 31 | } 32 | 33 | location / { 34 | #set $upstream_ http://; #ADD IP AND PORT OF SERVICE 35 | #proxy_pass $upstream_; #change name of the service 36 | set $upstream_whoogle http://192.168.1.101:5000; 37 | proxy_pass $upstream_whoogle>; 38 | 39 | auth_request /authelia; 40 | auth_request_set $target_url $scheme://$http_host$request_uri; 41 | auth_request_set $user $upstream_http_remote_user; 42 | auth_request_set $groups $upstream_http_remote_groups; 43 | proxy_set_header Remote-User $user; 44 | proxy_set_header Remote-Groups $groups; 45 | #error_page 401 =302 https://auth./?rd=$target_url; 46 | error_page 401 =302 https://auth.example.com/?rd=$target_url; 47 | 48 | client_body_buffer_size 128k; 49 | 50 | proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; 51 | 52 | send_timeout 5m; 53 | proxy_read_timeout 360; 54 | proxy_send_timeout 360; 55 | proxy_connect_timeout 360; 56 | 57 | proxy_set_header Host $host; 58 | proxy_set_header X-Real-IP $remote_addr; 59 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 60 | proxy_set_header X-Forwarded-Proto $scheme; 61 | proxy_set_header X-Forwarded-Host $http_host; 62 | proxy_set_header X-Forwarded-Uri $request_uri; 63 | proxy_set_header X-Forwarded-Ssl on; 64 | proxy_redirect http:// $scheme://; 65 | proxy_http_version 1.1; 66 | proxy_set_header Connection ""; 67 | proxy_cache_bypass $cookie_session; 68 | proxy_no_cache $cookie_session; 69 | proxy_buffers 64 256k; 70 | 71 | # add your ip range here, and remove this comment! 72 | set_real_ip_from 192.168.1.0/16; 73 | set_real_ip_from 172.0.0.0/8; 74 | real_ip_header X-Forwarded-For; 75 | real_ip_recursive on; 76 | } 77 | -------------------------------------------------------------------------------- /interface/authelia-config.yml: -------------------------------------------------------------------------------- 1 | ############################################################### 2 | # Authelia configuration | example.com ** EDIT befor use # 3 | ############################################################### 4 | 5 | server: 6 | host: 0.0.0.0 7 | port: 9091 # change to port in docker-compose.yml 8 | # read_buffer_size: 4096 9 | # write_buffer_size: 4096 10 | # For using your logo.png and favicon.ico 11 | # asset_path: /config/assets/ 12 | 13 | jwt_secret: miro6Roswejapr9mlt0eveb9WrLtR1 14 | 15 | default_redirection_url: https://ws.example.com 16 | 17 | totp: 18 | issuer: example.com 19 | period: 30 20 | skew: 1 21 | 22 | #duo_api: ## You can use this api if you want push notifications of auth attempts 23 | # hostname: api-123456789.example.com 24 | # integration_key: ABCDEF 25 | # secret_key: your syper secret and super string (characters and numbers and symbols) 26 | 27 | access_control: 28 | default_policy: deny # NginX domains are denied unless added below 29 | #networks: 30 | # - name: internal 31 | # networks: 32 | # - 192.168.1.0/24 33 | # - 172.17.0.0/24 34 | # - 172.18.0.0/24 35 | # - 172.19.0.0/24 36 | rules: 37 | # Rules applied to everyone 38 | - domain: 39 | - auth.example.com 40 | - www.example.com 41 | - whoogle.example.com 42 | - techblog.example.com 43 | policy: bypass 44 | 45 | - domain: 46 | - test.example.com 47 | - hakuna.example.com 48 | - stargate.example.com 49 | policy: one_factor 50 | 51 | - domain: 52 | - heimdall.example.com 53 | - ntop.example.com 54 | - nextcloud.example.com 55 | - ghost.example.com 56 | policy: two_factor 57 | 58 | authentication_backend: 59 | disable_reset_password: false 60 | file: 61 | path: /config/users.yml 62 | password: 63 | algorithm: argon2id 64 | #iterations: 1 65 | ##key_lenght 32 66 | #memory: 64 67 | #parallelism: 8 68 | ##salt_string: 69 | #salt_lenght: 16 70 | 71 | session: 72 | name: authelia_session 73 | # This secret can also be set using the env variables AUTHELIA_SESSION_SECRET_FILE 74 | secret: aComplicatedString30CharactersAndNumpers 75 | expiration: 1h # 3600# 1h or 600 10m 76 | inactivity: 7200 # 2h or 300 5m 77 | domain: example.com # your root protected domain 78 | 79 | redis: 80 | host: authelia_redis 81 | port: 6379 82 | # This secret can also be set using the env variables AUTHELIA_SESSION_REDIS_PASSWORD_FILE 83 | # The service will run without a password 84 | password: "SetYourPa$$wordForRedis" #authelia 85 | 86 | regulation: 87 | max_retries: 3 88 | find_time: 120 #2m 89 | ban_time: 600 #10m 90 | 91 | #storage: 92 | # encryption_key: aSecret666StringUsedForEncryptionSeed 93 | # local: 94 | # path: /config/db.sqlite3 95 | storage: 96 | encryption_key: "you_must_generate_a_random_string_of_more_than_twenty_chars_and_configure_this" 97 | mysql: 98 | host: authelia_db 99 | database: authelia 100 | username: authelia 101 | password: "Pa$$word" 102 | 103 | # Logging is set here 104 | log: 105 | level: info 106 | format: text 107 | #file_path: /config/authelia.log 108 | 109 | # Apperance of Authelia can be light or dark --------------------------------------- 110 | theme: dark # dark / light 111 | 112 | # Optional if your system has ntp implemented -------------------------------------- 113 | ntp: 114 | address: "time.cloudflare.com:123" 115 | version: 3 116 | max_desync: 3s 117 | disable_startup_check: false 118 | disable_failure: false 119 | 120 | # Notification by e-mail or file ---------------------------------------------------- 121 | notifier: 122 | disable_startup_check: false #true/false 123 | # filesystem: 124 | # filename: /config/notification.txt #if you want the psw into a file not in email 125 | smtp: 126 | username: admin@example.com 127 | password: your-mail-passwd 128 | host: mail.example.com 129 | port: 587 # 25 non-ssl, 443 ssl, 587 tls 130 | sender: admin@example.com 131 | subject: "[Authelia] {title}" 132 | disable_require_tls: false # set to true if your domain uses no tls or ssl only 133 | disable_html_emails: false # set to true if you don't want html in your emails 134 | tls: 135 | server_name: mail.example.com 136 | skip_verify: false 137 | minimum_version: TLS1.2 138 | -------------------------------------------------------------------------------- /interface/authelia.yml: -------------------------------------------------------------------------------- 1 | version: '3.3' 2 | 3 | services: 4 | #Authelia will give authentication support to NPM 5 | authelia: 6 | image: authelia/authelia 7 | container_name: authelia 8 | volumes: 9 | - ./config:/config 10 | # Ports will only be used if not in the same VM 11 | # ports: 12 | # - 9091:9091 13 | restart: unless-stopped #allways 14 | healthcheck: 15 | disable: true 16 | #healthcheck: 17 | # test: ["CMD", "curl", "--fail", "http://auth.example.com"] 18 | # interval: 1m30s 19 | # timeout: 10s 20 | # retries: 3 21 | environment: 22 | - TZ=Europe/Helsinki 23 | depends_on: 24 | - redis 25 | - db 26 | networks: 27 | - kadulla 28 | - pihalla 29 | # Redis is needed to run Authelia 30 | redis: 31 | image: redis:alpine 32 | command: redis-server --requirepass "4u7x!A%D*G-KaPdSgVkXp2s5v8y/B?E(" 33 | container_name: authelia_redis 34 | volumes: 35 | - ./redis:/data 36 | expose: 37 | - 6379 38 | restart: unless-stopped #always 39 | environment: 40 | - TZ=Europe/Helsinki 41 | networks: 42 | - pihalla 43 | # MariaDB is needed to run Authelia 44 | db: 45 | image: mariadb 46 | container_name: authelia_db 47 | restart: unless-stopped #always 48 | environment: 49 | MYSQL_RANDOM_ROOT_PASSWORD: 55 # We do not edit the db 50 | #MYSQL_ROOT_PASSWORD: 'LongComplicatedPa$$word' # replace-with-secure-password ${MYSQL_ROOT_> 51 | #MYSQL_ROOT_PASSWORD__FILE: /run/secrets/DB_ROOT_PWD 52 | MYSQL_DATABASE: 'authelia'ThisIsA_VeryLongAndSuper 53 | MYSQL_USER: 'authelia' 54 | MYSQL_PASSWORD: 'A_ComplicatedPa$$word' # replace-with-secure-password ${MYSQL_PASSWORD} 55 | #MYSQL_PASSWORD__FILE: /run/secrets/MYSQL_PWD 56 | volumes: 57 | - ./mysql:/var/lib/mysql 58 | networks: 59 | - pihalla 60 | 61 | # networks the services will use 62 | networks: 63 | kadulla: #frontend 64 | external: true 65 | pihalla: #backend 66 | external: true 67 | ... 68 | -------------------------------------------------------------------------------- /interface/authelia_ghost_rule: -------------------------------------------------------------------------------- 1 | Authelia rules for Ghost: 2 | 1. login to admin page - admins only 3 | 2. login to admin page - deny all other 4 | 3. enter Ghost pages - allow all 5 | 6 | # Allow admin users to sign in by 2FA 7 | - domain: 'test.example.com' 8 | policy: 'two-factor' 9 | subject: 10 | - 'groupe:admins' 11 | resources: 12 | - '^/ghost([/?].*$' 13 | # Deny everyone else from setup 14 | - domain: 'test.example.com' 15 | policy: 'deny' 16 | resources: 17 | - '^/ghost([/?].*$' 18 | # Allow everyone to watch pages 19 | - domain: 'test.example.com' 20 | policy: 'public' 21 | -------------------------------------------------------------------------------- /interface/npm.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: '3.7' 3 | 4 | services: 5 | # Nginx Proxy Manager 6 | npm: 7 | image: 'jc21/nginx-proxy-manager:latest' 8 | container_name: npm 9 | restart: unless-stopped #always 10 | ports: 11 | - '80:80' 12 | - '81:81' 13 | - '443:443' 14 | # Add any other Stream port you want to expose 15 | # - '21:21' # FTP 16 | volumes: 17 | - ./data:/data 18 | - ./letsencrypt:/etc/letsencrypt 19 | # - ./letsencrypt.ini:/etc/letsencrypt.ini:rw 20 | networks: 21 | - kadulla 22 | 23 | ## MariaDB if needed for corporate use 24 | # depends_on: 25 | # - db 26 | # 27 | # db: 28 | # image: 'jc21/mariadb-aria:latest' 29 | # restart: unless-stopped 30 | # environment: 31 | # MYSQL_ROOT_PASSWORD: 'SuperSecurePa$$word' 32 | # MYSQL_DATABASE: 'npm' 33 | # MYSQL_USER: 'npm' 34 | # MYSQL_PASSWORD: 'npmPa$$word' 35 | # volumes: 36 | # - ./data/mysql:/var/lib/mysql 37 | 38 | # Networks for the services 39 | networks: 40 | kadulla: 41 | external: true 42 | ## activate if using db 43 | # pihalla: 44 | # external: true 45 | 46 | ... 47 | -------------------------------------------------------------------------------- /interface/users: -------------------------------------------------------------------------------- 1 | #---------------------------------------------------------------------------# 2 | # Users Database List # 3 | # # 4 | # This file can be used if you do not have an LDAP set up. # 5 | # # 6 | # docker run authelia/authelia:latest authelia hash-password 'password' # 7 | # # 8 | #---------------------------------------------------------------------------# 9 | 10 | # List of users 11 | users: 12 | pomo: 13 | displayname: "Authelia User" 14 | # Password is authelia 15 | password: "$argon2id$v=19$m=65536,t=1,p=8$VDhpQnRsN2Jjbm05bVpKRw$l/d/aDI8N8DqIM/lQLstnDvxgvaWLGW2Rm8UAM9XXtc" 16 | email: authelia@authelia.com 17 | groups: 18 | - admins 19 | - dev 20 | 21 | user1: 22 | displayname: "User of power" 23 | password: "$argon2id$v=19$m=65536,t=1,p=8$VDhpQnRsN2Jjbm05bVpKRw$l/d/aDI8N8DqIM/lQLstnDvxgvaWLGW2Rm8UAM9XXtc" 24 | email: user@example.com 25 | groups: 26 | - admins 27 | - superusers 28 | - users 29 | - dev 30 | 31 | #---------------------------------------------------------------------------# 32 | # Use a password site with argon2 (see filesfor settings) # 33 | # docker run authelia/authelia:latest authelia hash-password 'password' # 34 | #---------------------------------------------------------------------------# 35 | -------------------------------------------------------------------------------- /monitorProxmox.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: '3' 3 | 4 | services: 5 | grafana: 6 | image: grafana/grafana-oss:latest 7 | container_name: grafana 8 | ports: 9 | - "3000:3000" 10 | volumes: 11 | - grafana-data:/var/lib/grafana 12 | restart: unless-stopped 13 | networks: 14 | - kadulla 15 | depends_on: 16 | - influxdb 17 | 18 | influxdb: 19 | image: influxdb:2.1-alpine 20 | container_name: influxdb 21 | restart: unless-stopped 22 | ports: 23 | - '8086:8086' 24 | volumes: 25 | - influxdb-data:/var/lib/influxdb2 26 | #- ./influxdb-data:/var/lib/influxdb2 27 | - /etc/influxdb2:/etc/influxdb2 28 | # # (optional) If you're using self-signed certs 29 | # - /etc/ssl/cert.pem/:/etc/ssl/cert.pem 30 | # - /etc/ssl/cert-key.pem/:/etc/ssl/cert-key.pem 31 | networks: 32 | - kadulla 33 | # # Automatically setup influxdb 34 | # TODO: not tested... 35 | # environment: 36 | # - DOCKER_INFLUXDB_INIT_MODE=setup 37 | # - DOCKER_INFLUXDB_INIT_USERNAME=my-user 38 | # - DOCKER_INFLUXDB_INIT_PASSWORD=my-password 39 | # - DOCKER_INFLUXDB_INIT_ORG=my-org 40 | # - DOCKER_INFLUXDB_INIT_BUCKET=my-bucket 41 | # # (optional) Configure Data Retention 42 | # - DOCKER_INFLUXDB_INIT_RETENTION=1w 43 | # # (optional) Admin Token 44 | # - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=my-super-secret-auth-token 45 | # # (optional) If you're using self-signed certs 46 | # command: influxd --tls-cert=/etc/ssl/cert.pem --tls-key=/etc/ssl/cert-key.pem 47 | 48 | # Netwoirks to be used 49 | networks: 50 | kadulla: 51 | external: true 52 | 53 | # Volumes to use 54 | volumes: 55 | grafana-data: 56 | driver: local 57 | influxdb-data: 58 | driver: local 59 | -------------------------------------------------------------------------------- /myTemplateBuilder.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #-----------------------------------------------------------------------------# 4 | # myTempBuilder.sh for Ubuntu 22.04 Servers # 5 | # Part of the MyJourney project @ homelab.casaursus.net/proxmox-automation # 6 | # # 7 | # V.1 Created by Nalle Juslén 29.11.2022 # 8 | # -review 1.12.2022 # 9 | # # 10 | # V.2 Created by Nalle Juslén 4.1.2023 # 11 | # - revison 9.1.2023, 29.1.2023 # 12 | # # 13 | # V.3 Created by Nalle Juslén 30.5.2023 # 14 | # - revison 31.5.2023, 1.6.2023, 12.10.2023 # 15 | # # 16 | # V.4 is released See the scripts section # 17 | # # 18 | # For more info see: https://pve.proxmox.com/pve-docs/qm.conf.5.html # 19 | # Date format and >>>> ---- <<<< **** for easy sorting # 20 | #-----------------------------------------------------------------------------# 21 | 22 | # Install this script by: 23 | # - open a terminal into the Proxmox node as root 24 | # - run wget://https://raw.githubusercontent.com/nallej/MyJourney/main/scripts/myTemplateBuilder.sh 25 | # - chmod +x myTemplateBuilder.sh 26 | # 27 | 28 | # Edit the script is very important: 29 | # - set memory size 30 | # - # of cores 31 | # - what apps do you need 32 | # - VM settings 33 | 34 | # Upload your key to use for auto creation to: 35 | # - ~/.ssh/my_key 36 | 37 | 38 | # Functions ==================================================================# 39 | 40 | usecolors() # Function: define colors 41 | { 42 | red=$'\e[1;31m' 43 | grn=$'\e[1;32m' 44 | yel=$'\e[1;33m' 45 | blu=$'\e[1;34m' 46 | mag=$'\e[1;35m' 47 | cyn=$'\e[1;36m' 48 | end=$'\e[0m' 49 | 50 | #Use them to print with colours: printf "%s\n" "Text in white ${blu}blue${end}, white and ${mag}magenta${end}." 51 | } 52 | 53 | spinner() # Function: display a animated spinner 54 | { 55 | # The different Spinner Arrays to choose from 56 | local array1=("◐" "◓" "◑" "◒") 57 | local array2=("░" "▒" "▓" "█") 58 | local array3=("╔" "╗" "╝" "╚") 59 | local array4=("┌" "┐" "┘" "└") 60 | local array5=("▄" "█" "▀" "█") 61 | local array6=('-' '\' '|' '/') # L to R 62 | local array7=('-' '/' '|' '\') # R to L 63 | local array9=("⠋" "⠙" "⠹" "⠸" "⠼" "⠴" "⠦" "⠧" "⠇" "⠏") 64 | 65 | local delays=0.1 # Delay between each characte 66 | 67 | tput civis # Hide cursor and spinn 68 | 69 | while :; do 70 | for character in "${array9[@]}"; do # Use this Array 71 | printf "%s" "$character" 72 | sleep "$delays" 73 | printf "\b" # Move cursor back 74 | done 75 | done 76 | } 77 | 78 | guestfs() # Function: install the libguestfs-tools 79 | { 80 | apt-get update 81 | apt-get install libguestfs-tools -y 82 | } 83 | 84 | getUbuntu() # Function: get a cloud image, Ubuntu as example, it's a .qcow2 fil with the extension img - we turn it back to .qcow2 85 | { 86 | if [[ $mini == [yY] ]]; then 87 | if [[ -f "mini.qcow2" && $upd == [yY] ]]; then 88 | cp mini.qcow2 base.qcow2 89 | else 90 | wget -O mini.qcow2 https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img 91 | cp mini.qcow2 base.qcow2 92 | fi 93 | else 94 | if [[ -f std.qcow2 && $upd == [yY] ]]; then 95 | cp std.qcow2 base.qcow2 96 | else 97 | wget -O std.qcow2 https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img 98 | cp std.qcow2 base.qcow2 99 | fi 100 | fi 101 | } 102 | 103 | createBase() # Function: create a fully loaded base ISO ### Set the Disk size ### set the apps needed #### 104 | { 105 | qemu-img resize base.qcow2 $ds #16G is typical - Resize the disk to your needs, 8 - 32G is normal 106 | # Add QEMU Guest Agent and any other packages you’d like in your base image. 107 | # libguestfs-tools has to be installed on the node. 108 | # Add or delete according to your needs 109 | virt-customize --install qemu-guest-agent -a base.qcow2 # Highly recommended 110 | virt-customize --install nano -a base.qcow2 # I like it 111 | virt-customize --install ncurses-term -a base.qcow2 # needed for terminals 112 | virt-customize --install git -a base.qcow2 # moustly needed 113 | virt-customize --install unattended-upgrades -a base.qcow2 # good feature 114 | virt-customize --install fail2ban -a base.qcow2 # highly recommended 115 | virt-customize --install clamav -a base.qcow2 # highly recommended 116 | virt-customize --install clamav-daemon -a base.qcow2 # linked to above 117 | virt-customize --install mailutils -a base.qcow2 # might be needed 118 | } 119 | 120 | createVM() # Funtion: creat a VM or a Template 121 | { 122 | # Choose RAM, Disk size, # of cores, what bridge to use. virtio is mandatory 123 | if [[ $mini == [yY] ]]; then 124 | qm create $tno --memory $ms --core $cc --name ubuntu-mini --net0 virtio,bridge=$vmbr,tag=$vlan 125 | else 126 | qm create $tno --memory $ms --core $cc --name ubuntu-std --net0 virtio,bridge=$vmbr,tag=$vlan 127 | fi 128 | 129 | # Import the disc to the base of the template. Where to put the VM local-lvm 130 | qm importdisk $tno base.qcow2 $storage 131 | 132 | # Attache the disk to the base of the template 133 | qm set $tno --scsihw virtio-scsi-pci --scsi0 $storage:vm-$tno-disk-0 134 | 135 | # Attach the cloudinit file - you NEED to EDIT it later ! 136 | qm set $tno --ide2 $storage:cloudinit 137 | 138 | # Make the cloud init drive bootable and only boot from this disk 139 | qm set $tno --boot c --bootdisk scsi0 140 | 141 | # Add serial console, to be able to see console output! 142 | qm set $tno --serial0 socket --vga serial0 143 | 144 | # Autostart vm at boot - default is 0 - Ususlly most VM's are allway running 145 | qm set $tno --onboot 1 146 | 147 | # Use Qemu Guest Agent - default is 0 148 | qm set $tno --agent 1 149 | 150 | # Set OS type Linux 5.x kernel 2.6 - default is other 151 | qm set $tno --ostype l26 152 | 153 | # Set dhcp on 154 | qm set $tno --ipconfig0 ip="dhcp" 155 | 156 | ## More automation can be added to cloud-init, examplesbelow -----------------# 157 | # 1. copy your public key to the node or copy it later to the VM 158 | #ssh-copy-id -i ~/.ssh/id_ed25519 username@pve.lab.example.com 159 | 160 | # 2. set up credentials 161 | qm set $tno --ciuser $ciu #"admin" # use your imagination 162 | qm set $tno --cipassword $cip # "Pa$$w0rd" # use a super complicated one 163 | if [[ $my_key == [yY] ]]; then 164 | qm set $tno --sshkey ~/.ssh/my_key # sets the users key to the vm 165 | fi 166 | 167 | # 3. use a bootstrap file at the initial boot that can have snippets. 168 | # You need to check the status of the Storage Manager and set according to yours 169 | #pvesm status 170 | #pvesm set local --content backup,iso,snippets,vztmpl 171 | #qm set $tno --cicustom "vendor=:snippets/vendor.yaml" 172 | 173 | } 174 | 175 | createTemplate() # Functin: Create the template ex. 9000 176 | { 177 | if [[ $tok == [yY] ]]; then 178 | qm template $tno 179 | sleep 2 180 | fi 181 | } 182 | 183 | createClones() # Functin: Cloning the template 184 | { 185 | if [[ $ctno -gt 0 ]]; then 186 | x=0 187 | while [ $x -lt $ctno ] 188 | do 189 | xx=$(($fcno + $x)) 190 | x=$(( $x + 1 )) 191 | qm clone $tno $xx --name $cname$x --full 192 | done 193 | fi 194 | } 195 | 196 | # Main =======================================================================# 197 | clear 198 | echo ">>>> Started the Install @ $(date +"%F %T") **** ****" > ~/installMTB.log 199 | echo -e "\e[1;35mThis script will create Templates and or VM's for your node.\e[0m" 200 | echo "" 201 | echo -e "\e[1;31mNOTE\e[1;35m - libguestfs-tools is needed. Installe it ones on Proxmox." 202 | echo "" 203 | echo " Remember to edit the script before executing: " 204 | echo " - base settings are 1 core and 1024M RAM" 205 | echo " - normal disk size for a VM is 8-16G or sometimes 32G" 206 | echo " - Enter Disk size as 8G NOT 8 !" 207 | echo -e " - OS = L26, IP = DHCP, QGA = on, Autostart = off\e[0m" 208 | echo "" 209 | echo -e "\e[1;33mStart the configuration\e[0m" 210 | read -rp " Install the libguestfs-tools Now [y/N] : " gfs 211 | echo "" 212 | echo -e "\e[1;35m Creating the Base Image from a Cloud image\e[0m" 213 | read -rp " - Change to minimal Ubuntu [y/N] : " mini 214 | read -rp " - Use existing ISO-image [y/N] : " upd 215 | read -rp " - Disk size (8, 16 or 32G) e.g 8G : " ds 216 | read -rp " - Memory (1024 is plenty) e.g.1024 : " ms 217 | read -rp " - Core count (1 is plenty) e.g. 1 : " cc 218 | read -rp " - Set vmbr to be used e.g. vmbr2 : " vmbr 219 | read -rp " - Set vlan tag e.g. 1 : " vlan 220 | echo -e "\e[1;35m Settings for the VM or Template and VMs\e[0m" 221 | read -rp " - Set VM or Template ID e.g. 9000 : " tno 222 | read -rp " - Storage to use VM e.g. local-lvm : " storage 223 | read -rp " - Create with CI user e.g. admin : " ciu 224 | #echo -n " - create with CI user password : " 225 | read -sp " - create with CI user password : " cip 226 | echo 227 | read -rp " - set key from ~/.ssh/my_key [y/N] : " my_key 228 | echo -e "\e[1;35m Settings for Template and VMs\e[0m" 229 | read -rp " - Create as a Template id $tno [y/N] : " tok 230 | if [[ $vlan < 1 ]]; then vlan=1; fi 231 | if [[ $tok == [yY] ]]; then 232 | read -rp " - Create # clones of $tno 0=no clones: " ctno 233 | if [[ $ctno -gt 0 ]]; then 234 | read -rp " - ID number for first clone 5000 : " fcno 235 | if [ $ctno = 1 ]; then 236 | xz=$fcno 237 | else 238 | xz=$(($fcno + $ctno)) 239 | fi 240 | read -rp " - name of clone's pod1 to pod$ctno : " cname 241 | echo -e "\e[1;33m Creating Template with ID $tno, $ds" 242 | echo " - creating cloned VM's $fcno - $xz" 243 | y=1 244 | echo -e " - named as $cname$y - $cname$ctno\e[0m" 245 | fi 246 | else 247 | echo "" 248 | echo -e "\e[1;33m - Creating a VM with ID $tno Disk $ds\e[0m" 249 | fi 250 | echo "" 251 | read -rp $'\e[1;31mStart the Install [y/N] : \e[0m' ok 252 | echo "" 253 | 254 | # init log 255 | if [[ $ok == [yY] ]]; then 256 | # Run the spinner in the background and Save the PID 257 | spinner & 258 | spinner_pid=$! 259 | 260 | # Execute the functions --------------------------------------------------# 261 | if [[ $gfs == [yY] ]]; then 262 | (guestfs >> ~/installMTB.log 2>&1) #& hyrra 263 | printf "\b \n" 264 | echo "Installed libguestfs-tools" 265 | echo "---- * libguestfs-tools @ $(date +"%F %T") **** ****" >> ~/installMTB.log 266 | fi 267 | sleep .5 268 | (getUbuntu >> ~/installMTB.log 2>&1) #& hyrra 269 | printf "\b" #\n" 270 | echo " - Cloud Image downloaded" 271 | echo "---- * CloudImage @ $(date +"%F %T") **** ****" >> ~/installMTB.log 272 | (createBase >> ~installMTB.log 2>&1) 273 | printf "\b" #\n" 274 | echo " - Base.qcow2 image created" 275 | echo "---- * base.qcov2 $ds image @ $(date +"%F %T") **** ****" >> ~/installMTB.log 276 | (createVM >> ~/installMTB.log 2>&1) #& hyrra 277 | printf "\b" # \n" 278 | echo " - VM created, $ds" 279 | echo "---- * VM Created $(date +"%F %T") **** ****" >> ~/installMTB.log 280 | if [[ $tok == [yY] ]]; then 281 | createTemplate &> /dev/null #& hyrra 282 | printf "\b" # \n" 283 | echo " - Template created, $ds" 284 | echo "---- * Template created @ $(date +"%F %T") **** ****" >> ~/installMTB.log 285 | 286 | fi 287 | if [[ $ctno -gt 0 ]]; then 288 | createClones &> /dev/null #& hyrra 289 | printf "\b" # \n" 290 | echo " - Clone(s) created" 291 | echo "---- * Clones created @ $(date +"%F %T") **** ****" >> ~/installMTB.log 292 | fi 293 | # End of Execute Functions------------------------------------------------# 294 | echo "<<<< Install ended OK @ $(date +"%F %T") **** ****" >> ~/installMTB.log 295 | 296 | # Terminate the Spinner 297 | kill "$spinner_pid" 298 | wait "$spinner_pid" 2>/dev/null 299 | 300 | # End messages 301 | if [[ $ctno -gt 0 ]]; then 302 | echo "" 303 | echo "Log created: ~/installMTB.log - check for errors" 304 | echo "" 305 | else 306 | echo "" 307 | tput setaf 3 308 | echo "Remenmer do NOT start the VM before making it into a template !" 309 | tput sgr0 310 | echo "Edit the Cloud-Init NOW ... then clone your VM's" 311 | tput setaf 1 312 | echo "" 313 | echo "WARNING - Do NOT start the VM - WARNING" 314 | tput sgr0 315 | # Alt way of output 316 | #useColors 317 | #printf "%s\n" "Remenmer do ${red}NOT4{end} start the VM before making it into a template !" 318 | #printf "%s\n" "Edit the Cloud-Init ${red}NOW${end} ... then clone your VM's" 319 | #printf "%s\n" "${red}WARNING${end} - Do ${red}NOT${end} start the VM - ${red}WARNING${end}." 320 | sleep 1 321 | echo "" 322 | echo "Log created: ~/installMTB.log - Check for errors" 323 | echo "" 324 | fi 325 | sleep 2 326 | else 327 | echo "<<<< Exited the Install @ $(date +"%F %T") **** ****" >> ~/installMTB.log 328 | fi 329 | # Show the Cursor Again 330 | tput cnorm 331 | 332 | read -rp "Print the log [Y/n] : " pl 333 | if [[ $pl -eq '' || $pl = [yY] ]]; then 334 | cat ~/installMTB.log 335 | fi 336 | -------------------------------------------------------------------------------- /myUpdater.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #------------------------------------------------------------------# 4 | # myUpdater.sh # 5 | # Part of the MyJourney project @ homelab.casaursus.net # 6 | # # 7 | # V.1 Created by Nalle Juslén 29.11.2022 # 8 | # -review 1.12.2022 # 9 | # # 10 | # V.2 Created by Nalle Juslén 4.1.2023 # 11 | # - revison # 12 | # # 13 | # Date format and >>>> ---- <<<< **** for easy sorting # 14 | # Updates for Debian (apt) and Redhat (dnf) based VM's # 15 | #------------------------------------------------------------------# 16 | 17 | # Function hyrraPyorii. Show a activity spinner 18 | hyrraPyorii () 19 | { 20 | pid=$! # PID of the previous running command 21 | x='-\|/' # hyrra in its elements 22 | i=0 23 | while kill -0 $pid 2>/dev/null 24 | do 25 | i=$(( (i+1) %4 )) 26 | printf "\r ${x:$i:1}" 27 | sleep .1 28 | done 29 | printf "\r " 30 | } 31 | #------------------------------------------------------------------# 32 | 33 | # Function end_msg 34 | end_msg () 35 | { 36 | if [ $? -ne 0 ] 37 | then 38 | echo "" 39 | echo "<<<< Ended with errors @ $(date +"%F %T") **** ****" >>$ei_log 40 | echo "ERROR! ERROR! ERROR!" 41 | echo "Error occurred while upgrading - check the log: $ei_log" 42 | echo "" 43 | else 44 | echo "" 45 | echo "<<<< Upgrade ended OK @ $(date +"%F %T") **** ****" >>$ok_log 46 | echo "<<<< No errors found @ $(date +"%F %T") **** ****" >>$ei_log 47 | echo "Update completed - please read the log: $ok_log" 48 | fi 49 | } 50 | #------------------------------------------------------------------# 51 | 52 | # Function start_log 53 | start_log () 54 | { 55 | echo ">>>> Update started @ $(date +"%F %T") **** ****" >$ok_log 56 | echo ">>>> Update started @ $(date +"%F %T") **** ****" >$ei_log 57 | } 58 | #------------------------------------------------------------------# 59 | 60 | # Function initUpdater 61 | initUpdater() 62 | { 63 | os_rel=/etc/os-release 64 | pvm=`date "+%Y-%m-%d"` 65 | ok_log=/var/log/updater/"$pvm"_update_ok.log 66 | ei_log=/var/log/updater/"$pvm"_update_error.log 67 | if [ ! -d "/var/log/updater/" ] 68 | then 69 | sudo mkdir /var/log/updater 70 | sudo chown $me:users /var/log/updater 71 | sudo chmod g+w /var/log/updater 72 | fi 73 | if [ ! -f $ok_log ] 74 | then 75 | sudo touch $ok_log 76 | sudo chown $me:users $ok_log 77 | fi 78 | if [ ! -f $ei_log ] 79 | then 80 | sudo touch $ei_log 81 | sudo chown $me:users $ei_log 82 | fi 83 | #------------------------------------------------------------------# 84 | } 85 | 86 | # Function startUpdater 87 | startUpdater() 88 | { 89 | # Debian/Ubuntu/PopOS based ---------------------------------------# 90 | if grep -q "debian" $os_rel 91 | then 92 | echo -e "\b You are running a Debian based OS - Debian, Ubuntu, PopOS ..." 93 | sudo apt-get update 1>>$ok_log 2>>$ei_log 94 | sudo echo "---- Upgrade started @ $(date +"%F %T") **** ****" >>$ok_log 95 | sudo echo "---- Upgrade started @ $(date +"%F %T") **** ****" >>$ei_log 96 | sudo apt-get dist-upgrade -y 1>>$ok_log 2>>$ei_log 97 | # Redhat/Fedora/CentOS --------------------------------------------# 98 | elif grep -q "CentOs" $os_rel || grep -q "Fedora" $os_rel || grep -q "redhat" 99 | then 100 | echo -e "\b You are running a Fedora or Redhat 8 based OS" 101 | sudo dnf upgrade -y 1>>$ok_log 2>>$ei_log 102 | else 103 | echo "" 104 | echo "WARNING - Wrong OS for myUpdater!" 105 | echo "" 106 | fi 107 | } 108 | 109 | # Main ==============================================================# 110 | clear 111 | me="${SUDO_USER:-${USER}}" 112 | echo "" 113 | echo "You, $me are running:" 114 | grep -E '^(VERSION|NAME)=' /etc/os-release 115 | echo "" 116 | echo "" 117 | read -rp "Do you want to upgrade this VM [y/N]: " UPG 118 | echo "" 119 | if [[ "$UPG" = [yY] ]]; then 120 | initUpdater 121 | start_log 122 | startUpdater & hyrraPyorii 123 | end_msg 124 | # Post upgrade messsge 125 | echo "" 126 | echo "" 127 | read -rp " Do you want to see the error-log [y/N]: " SEL 128 | if [[ "$SEL" = [yY] ]]; then 129 | cat $ei_log 130 | fi 131 | echo "" 132 | read -rp " Do you like to see the ok-log [y/N]: " SOK 133 | if [[ "$SOK" = [yY] ]]; then 134 | cat $ok_log 135 | fi 136 | fi 137 | # ====================================================================# 138 | -------------------------------------------------------------------------------- /myVMsetup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #------------------------------------------------------------------# 4 | # myVMsetup.sh # 5 | # Part of the MyJourney project @ homelab.casaursus.net # 6 | # # 7 | # V.1 Created by Nalle @ 5.1.2023 # 8 | # -review 9.1.2023 # 9 | # # 10 | #------------------------------------------------------------------# 11 | 12 | hyrra() # Function - Shows the activity spinner 13 | { 14 | pid=$! # PID of the previous running command 15 | x='-\|/' # hyrra in its elements 16 | i=0 17 | while kill -0 $pid 2>/dev/null 18 | do 19 | i=$(( (i+1) %4 )) 20 | printf "\r ${x:$i:1}" 21 | sleep .1 22 | done 23 | printf "\r " 24 | } 25 | 26 | 27 | askOS() #Function to get the OS 28 | { 29 | os_rel=/etc/os-release 30 | if grep -q "debian" $os_rel 31 | then 32 | myOS=1 33 | elif grep -q "CentOs" $os_rel || grep -q "Fedora" $os_rel || grep -q "redhat" 34 | then 35 | myOS=2 36 | else 37 | echo "" 38 | echo "WARNING - Wrong OS for myVMsetop!" 39 | echo "" 40 | exit 41 | fi 42 | } 43 | 44 | 45 | askTZ() #Function - get the TimeZone variable 46 | { 47 | echo "" 48 | echo "What Time zone (TZ) do you use" 49 | read -rp " Your area (Europe): " YA 50 | read -rp " Your City (Helsinki): " YC 51 | myTZ=$YA/$YC 52 | echo "" 53 | PS3="TZ = $myTZ - is this correct? [1=No 2=Yes] " 54 | select _ in \ 55 | " No - incorrect location" \ 56 | " Yes - this is my place" \ 57 | " Exit" 58 | do 59 | case $REPLY in 60 | 1) askTZ ;; 61 | 2) nextPart ;; 62 | *) echo " Invalid selection, please try again " ;; 63 | esac 64 | done 65 | } 66 | 67 | 68 | nextPart() #Function to install needed parts 69 | { 70 | askAPPS 71 | installBaseApps 72 | if [[ $myOS = 1 ]] 73 | then 74 | doAppInstall 75 | elif [[ $myOS = 2 ]] 76 | then 77 | installDNF 78 | else 79 | echo " Error - Invalid OS " 80 | exit 81 | fi 82 | } 83 | 84 | 85 | 86 | end_msg() # Function - final messages into log-files 87 | { 88 | if [ $? -ne 0 ] 89 | then 90 | echo "" 91 | echo "<<<< Ended with errors @ $(date +"%F %T") **** ****" >>$ei_log 92 | echo "ERROR! ERROR! ERROR!" 93 | echo "Error occurred while upgrading - check the log: $ei_log" 94 | echo "" 95 | else 96 | echo "" 97 | echo "<<<< Upgrade ended OK @ $(date +"%F %T") **** ****" >>$ok_log 98 | echo "<<<< No errors found @ $(date +"%F %T") **** ****" >>$ei_log 99 | echo "Update completed - please read the log: $ok_log" 100 | fi 101 | } 102 | 103 | 104 | start_log() # Function - initialize the log-files 105 | { 106 | echo ">>>> Update started @ $(date +"%F %T") **** ****" >$ok_log 107 | echo ">>>> Update started @ $(date +"%F %T") **** ****" >$ei_log 108 | } 109 | 110 | 111 | initUpdater() # Function initUpdater - initialize variables and log-files 112 | { 113 | #os_rel=/etc/os-release 114 | pvm=`date "+%Y-%m-%d"` 115 | ok_log=/var/log/updater/"$pvm"_update_ok.log 116 | ei_log=/var/log/updater/"$pvm"_update_error.log 117 | if [[ ! -d "/var/log/updater/" ]]; then 118 | sudo mkdir /var/log/updater 119 | sudo chown $me:users /var/log/updater 120 | sudo chmod g+w /var/log/updater 121 | fi 122 | if [[ ! -f $ok_log ]]; then 123 | sudo touch $ok_log 124 | sudo chown $me:users $ok_log 125 | fi 126 | if [[ ! -f $ei_log ]]; then 127 | sudo touch $ei_log 128 | sudo chown $me:users $ei_log 129 | fi 130 | } 131 | 132 | 133 | startUpdater() # Function startUpdater 134 | { 135 | if [[ $myOS -eq 1 ]] #grep -q "debian" $os_rel # Debian/Ubuntu/PopOS based 136 | then 137 | echo -e "\b You are running a Debian based OS - Debian, Ubuntu, PopOS ..." 138 | sudo apt-get update 1>>$ok_log 2>>$ei_log 139 | sudo echo "---- Upgrade started @ $(date +"%F %T") **** ****" >>$ok_log 140 | sudo echo "---- Upgrade started @ $(date +"%F %T") **** ****" >>$ei_log 141 | sudo apt-get dist-upgrade -y 1>>$ok_log 2>>$ei_log 142 | elif [[ $myOS -eq 2 ]] #grep -q "CentOs" $os_rel || grep -q "Fedora" $os_rel || grep -q "redhat" # Redhat/Fedora/CentOS 143 | then 144 | echo -e "\b You are running a Fedora or Redhat 8 based OS" 145 | sudo dnf upgrade -y 1>>$ok_log 2>>$ei_log 146 | else 147 | echo "" 148 | echo "WARNING - Wrong OS for myVMsetop!" 149 | echo "" 150 | exit 151 | fi 152 | } 153 | 154 | 155 | installBaseApps() # Function installs basic apps and features 156 | { 157 | echo "" 158 | echo "Starting upgrade/install of apps for the Docker-stack" 159 | echo "" 160 | #lsb_release -a #print lsb-release info 161 | echo "" 162 | echo " Starting the Install " 163 | sleep 3 164 | read -rp " - Do you want to do the Install [y/n] " DPI 165 | if [[ "$DPI" = [yY] ]]; then 166 | echo " - Running VM updates and installs ..." 167 | echo " - The logfile is opend in your home directory - install.log" 168 | # Add bash_aliases and prompt-------------------------------------------------- 169 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/.bash_aliases &> /dev/null 170 | wget https://raw.githubusercontent.com/nallej/MyJourney/main/.bash_prompt &> /dev/null 171 | (. ~/.bash_aliases) >> ~/install.log 2>&1 172 | echo " - added .bash_aliases" 173 | # Add bash_aliases ------------------------------------------------------------ 174 | sudo timedatectl set-timezone "$myTZ" 175 | echo " - Setting up unattenden updates = yes " 176 | (sudo systemctl enable unattended-upgrades --now) >> ~/install.log 2>&1 177 | echo "" 178 | echo " WARNING - Do you want to clear old updates?" 179 | read -rp " - Clear old updates [y/n] " COU 180 | if [[ "$COU" = [yY] ]]; then 181 | echo " - Deliting old installs ..." 182 | sudo apt-get clean >> ~/install.log 2>&1 183 | sudo apt-get autoremove >> ~/install.log 2>&1 184 | fi 185 | if [[ ! -d "~/docker/" ]]; then 186 | mkdir ~/docker 187 | echo " + Added the dir [~/docker] for the Docker-stack " 188 | fi 189 | else 190 | exit 191 | fi 192 | } 193 | 194 | askAPPS() #Function - What to install 195 | { 196 | isDOCE=$( (sudo systemctl is-active docker ) 2>&1 ) 197 | isDOCO=$( (docker-compose -v ) 2>&1 ) 198 | echo "" 199 | echo "NOTE: Without Docker you cannot use Docker-Compose, NGinx Proxy Manager, or Portainer-CE." 200 | echo " You also must have Docker-Compose for NGinX Proxy Manager to be installed." 201 | echo "NOTE: - Portainer-ce - Web GUI for Docker, Swarm and Kubernetes" 202 | echo " - Portainer Agent - Remote Agent for other Portainer-ce to Connect to" 203 | echo "" 204 | if [[ "$isDOCE" != "active" ]] 205 | then 206 | echo "Please install Docker-ce" 207 | #echo "" 208 | else 209 | echo "Note -> Docker appears to be installed and running." 210 | #echo "" 211 | fi 212 | if [[ "$isDOCO" == *"command not found"* ]] 213 | then 214 | echo "Please install Docker-Compose" 215 | echo "" 216 | else 217 | echo "Note -> Docker-compose appears to be installed." 218 | echo "" 219 | fi 220 | echo "You need to install these apps:" 221 | read -rp " Docker-ce [y/n] " DOCE 222 | read -rp " Docker-Compose [y/n] " DOCO 223 | echo "Good to have: Portainer or it's Agent " 224 | read -rp " - Portainer-ce [y/n] " POT 225 | read -rp " - Portainer Agent [y/n] " POTA 226 | echo "" 227 | echo "Apps you can set up via Portainer or Docker-Compose." 228 | echo "Recommended apps:" 229 | read -rp " WatchTower, updater [y/n] " WT 230 | read -rp " Dozzle, reading logs [y/n] " DOZ 231 | echo "" 232 | echo "Optional apps " 233 | read -rp " - NGinX Proxy Manager [y/n] " NPM 234 | read -rp " - Heimdall [y/n] " HEIM 235 | read -rp " - Authelia [y/n] " AUTH 236 | read -rp " - Bind9 DNS, ICS-DHCP [y/N] " DNS 237 | } 238 | 239 | 240 | doAppInstall() # Function to install the Apps 241 | { 242 | if [[ "$DOCE" == [yY] ]]; then 243 | installDOCE 244 | fi 245 | if [[ "$DOCO" == [yY] ]]; then 246 | installDOCO 247 | fi 248 | if [[ "$POT" == [yY] ]]; then 249 | installPOT 250 | fi 251 | if [[ "$POTA" == [yY] ]]; then 252 | installPOTA 253 | fi 254 | if [[ "$WT" == [yY] ]]; then 255 | installWT 256 | fi 257 | if [[ "$DOZ" == [yY] ]]; then 258 | installDOZ 259 | fi 260 | if [[ "$HEIM" == [yY] ]]; then 261 | installHEIM 262 | fi 263 | if [[ "$NPM" == [yY] ]]; then 264 | installNPM 265 | fi 266 | if [[ "$AUTH" == [yY] ]]; then 267 | installAUTH 268 | fi 269 | if [[ "$DNS" == [yY] ]]; then 270 | installDNS 271 | fi 272 | 273 | echo "" 274 | echo "Basic installation done!" 275 | echo " - add services: prometheus, node-reporter, backup ..." 276 | echo " - add your apps wp, ghost, pfSense, Zabbix ...." 277 | echo " - logout and login again to activate permissions" 278 | echo " - please reboot node befor starting apps" 279 | echo "" 280 | echo "Rememper to have fun! Learn new things and love the CLI." 281 | echo "" 282 | exit 283 | } 284 | 285 | installDOCE() # Funtion installing Docker-ce on this VM 286 | { 287 | #sudo ls &> /dev/null # dummy to get sudo psw if user not part of SUDO groupe 288 | echo "Installing Docker-ce" 289 | sudo curl -fsSL https://get.docker.com | sh >> ~/install.log 2>&1 & hyrra 290 | echo "" 291 | echo " - Docker-ce installed. " 292 | echo " - Starting docker." 293 | echo "" 294 | (sleep 10s 295 | sudo systemctl enable docker 296 | sudo systemctl enable containerd.service 297 | sudo systemctl start docker 298 | sleep 5s 299 | docker -v 300 | sleep 2s 301 | sudo usermod -aG docker "$me" # you do not need to sudo to run docker commands after re-login 302 | sleep 1s) >> ~/install.log 2>&1 & hyrra 303 | sudo docker network create -d bridge kadulla &> /dev/null #frontend 304 | sudo docker network create -d bridge pihalla &> /dev/null #backbone 305 | echo " - $me added to the docker group (active after next login)." 306 | echo "" 307 | echo " - Internal networks created:" 308 | echo " - kadulla = frontend " 309 | echo " - pihalla = backbone " 310 | echo "" 311 | } 312 | 313 | 314 | installDOCO() # Funtion installing Docker-Compose on this VM 315 | { 316 | ( sudo apt install -q docker-compose -y ) >> ~/install.log 2>&1 #& hyrra 317 | echo " - Docker-Compose installed." 318 | echo "" 319 | sleep 2 320 | verDOCO=$(docker-compose --version) 321 | echo " - Version is: $verDOCO" 322 | echo "" 323 | sleep 1 324 | } 325 | 326 | 327 | installPOT() #Function installing Portainer-ce on this VM 328 | { 329 | ( sudo docker volume create portainer_data 330 | sudo docker run -d \ 331 | -p 8000:8000 \ 332 | -p 9000:9000 \ 333 | --name=portainer \ 334 | --restart=always \ 335 | -v /var/run/docker.sock:/var/run/docker.sock \ 336 | -v portainer_data:/data \ 337 | portainer/portainer-ce ) >> ~/install.log 2>&1 & hyrra 338 | echo " - Portainer can now be found @ ip x.x.x.x:9000" 339 | echo "" 340 | } 341 | 342 | 343 | installPOTA() # Function installing Portainer Agent on this VM 344 | { 345 | ( sudo docker volume create portainer_data 346 | sudo docker run -d \ 347 | -p 9001:9001 \ 348 | --name portainer_agent \ 349 | --restart=always \ 350 | -v /var/run/docker.sock:/var/run/docker.sock \ 351 | -v /var/lib/docker/volumes:/var/lib/docker/volumes \ 352 | portainer/agent) >> ~/install.log 2>&1 & hyrra 353 | echo " - Portainer finds this agent @ ip x.x.x.x:9001" 354 | echo "" 355 | } 356 | 357 | installWT() # Function installing WatchTower on this VM 358 | { 359 | if [[ ! -d "~/docker/watchtower/" ]]; then 360 | mkdir ~/docker/watchtower 361 | fi 362 | #cd ~/docker/watchtower 363 | wget -P ~/docker/watchtower https://raw.githubusercontent.com/nallej/MyJourney/main/watchtower/docker-compose.yml &> /dev/null 364 | # uncomment the next line if you want to start it now 365 | # docker-compose up -d 366 | echo "Watchtower installed" 367 | echo " - Updating images daily 04.00 " 368 | echo " - NOT started, edit befor starting" 369 | echo "" 370 | } 371 | 372 | 373 | installDOZ() # Function installing Dozzle log reader on this VM 374 | { 375 | if [[ ! -d "~/docker/dozzle/" ]]; then 376 | mkdir ~/docker/dozzle 377 | fi 378 | wget -P ~/docker/dozzle https://raw.githubusercontent.com/nallej/MyJourney/main/dozzle/docker-compose.yml &> /dev/null 379 | # uncomment the next line if you want to start it now 380 | # sudo docker-compose up -d 381 | ## Uncomment the next line if you want to ask 382 | #read -rp "Start Dozzle now [yN] startDOZ 383 | #if [[ "$startDOZ" == [yY] ]]; then 384 | # docker-compose up -d 385 | # sleep 2 386 | #fi 387 | echo "Dozzle config installed" 388 | echo " - Not started, EDIT befor using" 389 | echo " - ports: 9999" 390 | echo "" 391 | } 392 | 393 | 394 | installHEIM() # Function installing Heimdall Dashboard app on this VM 395 | { 396 | if [[ ! -d "~/docker/heimdall/" ]]; then 397 | mkdir ~/docker/heimdall 398 | fi 399 | wget -P ~/docker/heimdall https://raw.githubusercontent.com/nallej/MyJourney/main/heimdall/docker-compose.yml &>/dev/null 400 | # Uncomment the next line if you want to start it now 401 | #docker-compose up -d 402 | ## Uncomment the next line if you want to ask 403 | #read -rp "Start the Heimdall now [yN] startHEIM 404 | #if [[ "$startHEIM" == [yY] ]]; then 405 | # docker-compose up -d 406 | # sleep 2 407 | #fi 408 | echo "Heimdal config installed" 409 | echo " - Not started, EDIT befor using" 410 | echo " - default user/group: 1000/1000" 411 | echo " - ports: 9080 or 9088 " 412 | echo "" 413 | sleep 2 414 | } 415 | 416 | 417 | installNPM() # Funtion for installing NGinX Proxy Manager on this VM 418 | { 419 | if [[ ! -d "~/docker/npm/" ]]; then 420 | mkdir ~/docker/npm 421 | fi 422 | curl -o ~/docker/npm/docker-compose.yml https://raw.githubusercontent.com/nallej/MyJourney/main/interface/npm.yml &>/dev/null 423 | # Uncomment the next line if you want to start it now 424 | #docker-compose up -d 425 | ## Uncomment the next line if you want to ask 426 | #read -rp "Start NPM now [yN] startNPM 427 | #if [[ "$startNPM" == [yY] ]]; then 428 | # docker-compose up -d 429 | # sleep 2 430 | #fi 431 | echo "NGinX Proxy Manager is installed" 432 | echo " - Start and go to your server on port 81 to setup NPM admin account." 433 | echo " - default login credentials for NPM are:" 434 | echo " username: admin@example.com" 435 | echo " password: changeme" 436 | echo "" 437 | sleep 3 438 | } 439 | 440 | 441 | installAUTH() # Function to install Authelia on this VM 442 | { 443 | if [[ ! -d "~/docker/authelia/" ]]; then 444 | mkdir ~/docker/authelia 445 | mkdir ~/docker/authelia/config 446 | mkdir ~/docker/authelia/config/assets/ 447 | mkdir ~/docker/authelia/npm-advanced-cfgs 448 | fi 449 | curl -o ~/docker/authelia/config/docker-compose.yml https://raw.githubusercontent.com/nallej/MyJourney/main/interface/authelia-config.yml &>/dev/null 450 | curl -o ~/docker/authelia/config/users.yml https://raw.githubusercontent.com/nallej/MyJourney/main/interface/users &>/dev/null 451 | curl -o ~/docker/authelia/npm-advanced-cfgs/npm.site.advanced.cfg https://raw.githubusercontent.com/nallej/MyJourney/main/interface/authelia-cfg-site &>/dev/null 452 | curl -o ~/docker/authelia/npm-advanced-cfgs/npm.auth.advanced.cfg https://raw.githubusercontent.com/nallej/MyJourney/main/interface/authelia-cfg-auth &>/dev/null 453 | echo "Authelia config and other files are is installed" 454 | echo " - Start and go to your server for setting up the autentication services" 455 | echo "" 456 | sleep 3 457 | } 458 | 459 | installDNS() #Function to install Bind9 DNS server 460 | { 461 | if [[ ! -d "~/docker/dns/" ]]; then 462 | mkdir ~/docker/dns 463 | mkdir ~/docker/dns/cache 464 | mkdir ~/docker/dns/config 465 | mkdir ~/docker/dns/records 466 | mkdir ~/docker/dns/dhcp 467 | mkdir ~/docker/dns/dhcp/data 468 | fi 469 | wget -P ~/docker/dns/ https://raw.githubusercontent.com/nallej/MyJourney/main/dns/docker-compose.yml &>/dev/null 470 | wget -P ~/docker/dns/config/ https://raw.githubusercontent.com/nallej/MyJourney/main/dns/config/db.lab-example-com.zones &>/dev/null 471 | wget -P ~/docker/dns/config/ https://raw.githubusercontent.com/nallej/MyJourney/main/dns/config/db.182.168.1 &>/dev/null 472 | wget -P ~/docker/dns/config/ https://raw.githubusercontent.com/nallej/MyJourney/main/dns/config/named.conf &>/dev/null 473 | wget -P ~/docker/dns/dhcp/ https://raw.githubusercontent.com/nallej/MyJourney/main/dns/dhcp/docker-compose.yml &>/dev/null 474 | wget -P ~/docker/dns/dhcp/data/ https://raw.githubusercontent.com/nallej/MyJourney/main/dns/dhcp/data/dhcp.conf &>/dev/null 475 | echo "Bind 9 files are installed" 476 | echo " - Edit the files in ~/docker/dns/config before starting" 477 | echo " - db.lab-example-com.zones db.192.168.1 & named.conf" 478 | echo " - Edit resolved.conf" 479 | echo " - sudo nano /etc/systemd/resolved.conf" 480 | echo " - sudo systemctl restart systemd-resolved" 481 | echo " - sudo systemctl status systemd-resolved" 482 | echo " - Start your Bind9 DNS" 483 | echo "" 484 | echo " Optional ICS-DHCP" 485 | echo " - Edit ~/dns/docker-compose.yml" 486 | echo " - Edit the ~/docker/dnd/dhcp/data/dhcpd.conf" 487 | echo " - Start ICS-DHCP" 488 | echo "" 489 | sleep 3 490 | } 491 | 492 | 493 | # Main ======================================================= 494 | 495 | clear 496 | askOS 497 | me="${SUDO_USER:-${USER}}" 498 | echo "" 499 | echo "You, $me are running:" 500 | grep -E '^(VERSION|NAME)=' /etc/os-release 501 | echo "" 502 | echo "" 503 | echo "Create a Docker based VM" 504 | echo "---------------------------------------------------------------------------------" 505 | echo "" 506 | echo " WARNING - DON'T run scripts you download from the net without checking it first" 507 | echo " WARNING - Read the code - edit it and then run it!" 508 | echo "" 509 | echo " Warning, this script will pull additional parts from my GitHub" 510 | echo "" 511 | sleep 3 512 | read -rp "Do you want to SetUp this VM [y/N]: " SUP 513 | if [[ "$SUP" != [yY] ]] 514 | then 515 | exit 516 | fi 517 | echo "" 518 | read -rp "Do you want to upgrade this VM [y/N]: " UPG 519 | echo "" 520 | if [[ "$UPG" = [yY] ]] 521 | then 522 | initUpdater 523 | start_log 524 | startUpdater & hyrra 525 | end_msg 526 | # Post upgrade messsge 527 | echo "" 528 | echo "" 529 | read -rp " Do you want to see the error-log [y/N]: " SEL 530 | if [[ "$SEL" = [yY] ]]; then 531 | cat $ei_log 532 | fi 533 | echo "" 534 | read -rp " Do you like to see the ok-log [y/N]: " SOK 535 | if [[ "$SOK" = [yY] ]]; then 536 | cat $ok_log 537 | fi 538 | else 539 | if [[ $myOS = 1 ]]; then 540 | echo " - Performing apt-update " 541 | (sudo apt-get update &> /dev/null) & hyrra 542 | else 543 | sudo dnf upgrade 544 | echo " Please reboot the VM" 545 | echo " - and then test for errors: " 546 | echo " dmesg | egrep -i 'error|critical|warn|failed'" 547 | fi 548 | fi 549 | 550 | # Starting installation of apps 551 | echo "" 552 | echo "Current system Time zone (TZ) is: $(cat /etc/timezone)" 553 | read -rp " - Do you want to change [y/N] " CTZ 554 | if [[ "$CTZ" = [yY] ]]; then 555 | askTZ 556 | else 557 | nextPart 558 | fi -------------------------------------------------------------------------------- /scripts/ColorTest.sh: -------------------------------------------------------------------------------- 1 | ## Font attributes ## 2 | # off 3 | #off = '\x1b[0m' # off 4 | default='\e[39m' # default foreground 5 | DEFAULT='\e[49m' # default background 6 | # 7 | #bd = '\x1b[1m' # bold 8 | #ft = '\x1b[2m' # faint 9 | #st = '\x1b[3m' # standout 10 | #ul = '\x1b[4m' # underlined 11 | #bk = '\x1b[5m' # blink 12 | #rv = '\x1b[7m' # reverse 13 | #hd = '\x1b[8m' # hidden 14 | #nost = '\x1b[23m' # no standout 15 | #noul = '\x1b[24m' # no underlined 16 | #nobk = '\x1b[25m' # no blink 17 | #norv = '\x1b[27m' # no reverse 18 | 19 | ## Background Colors 20 | BLACK='\e[40m' 21 | RED='\e[41m' 22 | GREEN='\e[42m' 23 | YELLOW='\e[43m' 24 | BLUE='\e[44m' 25 | MAGENTA='\e[45m' 26 | CYAN='\e[46m' 27 | WHITE='\e[47m' 28 | ### Dark/Light BG 29 | DGRAY='\e[100m' 30 | LRED='\e[101m' 31 | LGREEN='\e[102m' 32 | LYELLOW='\e[103m' 33 | LBLUE='\e[104m' 34 | LMAGENTA='\e[105m' 35 | LCYAN='\e[106m' 36 | LGRAY='\e[107m' 37 | 38 | 39 | # Foreground Colors 40 | black='\e[30m' 41 | red='\e[31m' 42 | green='\e[32m' 43 | yellow='\e[33m' 44 | blue='\e[34m' 45 | magenta='\e[35m' 46 | cyan='\e[36m' 47 | white='\e[37m' 48 | 49 | # Dark/Light colors 50 | dgray='\e[90m' 51 | lred='\e[91m' 52 | lgreen='\e[92m' 53 | lyellow='\e[93m' 54 | lblue='\e[94m' 55 | lmagenta='\e[95m' 56 | lcyan='\e[96m' 57 | lgray='\e[97m' 58 | 59 | ## 256 colors ## 60 | # \x1b[38;5;#m foreground, # = 0 - 255 61 | # \x1b[48;5;#m background, # = 0 - 255 62 | ## True Color ## 63 | # \x1b[38;2;r;g;bm r = red, g = green, b = blue foreground 64 | # \x1b[48;2;r;g;bm r = red, g = green, b = blue background 65 | 66 | echo -e "${red} Printing red" 67 | echo -e "${green} Printing green" 68 | echo -e "${yellow} Yellow" 69 | echo -e "${blue} Blue" 70 | echo -e "${magenta} Magenta" 71 | echo -e "${cyan} Cyan" 72 | echo -e "${white} White" 73 | echo -e "${dgray} Dark Grey" 74 | echo -e "${lred} Light Red" 75 | echo -e "${lgreen} Light Green" 76 | echo -e "${lyellow} Light Yellow" 77 | echo -e "${lblue} Light Blue" 78 | echo -e "${lmagenta} Light Magenta" 79 | echo -e "${lcyan} Light Cyan" 80 | echo -e "${lgray} Light Grey" 81 | 82 | # Other 83 | ECS=$(echo "\e[m") # End of Color Statement 84 | 85 | bred=$(echo "\e[1;31m") 86 | echo -e "${bred} Bold Red " 87 | bgreen=$(echo "\e[1;92m") # Bold Brite Light Green 88 | echo -e "${bgreen} Bold Brite Light Gren" 89 | Purple=$(echo "\e[1;95m") # Bold Purple 90 | echo -e "${Purple} Purple" 91 | WGN=$(echo "\e[1;37;1;42m") # Bold White in Bold Green Box 92 | WYW=$(echo "\e[1;37;1;43m") # Bold White in Bold Yellow Box 93 | WRD=$(echo "\e[1;37;1;41m") # Bold White in Bold Red Box 94 | echo -e "${WGN} Bold White in Bold Green Box${ECS}" 95 | echo -e "${WYW} Bold White in Bold Yellow Box${ECS}" 96 | echo -e "${WRD} Bold White in Bold Red Box${ECS}" 97 | ugreen=$(echo "\e[4;92m") # Underline Brite Light Green 98 | echo -e "${ugreen} Underline Green ${ECS}" 99 | echo -e "\e[1;95;1;46mTest text${ECS}" 100 | 101 | 102 | # 103 | ## End and RESET 104 | echo -e "⚠️ End of FG${default} and ${DEFAULT}end of BG ${endcs} end of Color Test" -------------------------------------------------------------------------------- /scripts/DoDoDeb.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Create a VM running Docker & Dockge for our stacks 3 | # Run as normal user in ~/ 4 | # wget https://github.com/nallej/MyJourney/raw/main/scripts/DoDoDeb.sh 5 | 6 | # Make the directory for oure stacks 7 | mkdir -p /home/$USER/docker/ 8 | # refresh and upgrade 9 | apt update && apt upgrade -y 10 | # Prerequisits 11 | apt install -y apt-transport-https ca-certificates curl software-properties-common 12 | # GPG docker-archive-keyring 13 | curl -fsSL https://download.docker.com/linux/debian/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg 14 | echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null 15 | # Housekeeping 16 | sudo apt update 17 | # Install Docker-ce 18 | # sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin 19 | sudo apt install -y docker-ce 20 | # Install Dockge 21 | sudo docker run -d -p 5001:5001 --name Dockge --restart=unless-stopped -v /var/run/docker.sock:/var/run/docker.sock -v /home/$USER/docker/dockge/data:/app/data -v /home/$USER/docker/stacks:/home/$USER/docker/stacks -e DOCKGE_STACKS_DIR=/home/$USER/docker/stacks louislam/dockge:latest 22 | 23 | # extra stuff 24 | #systemctl start docker.service 25 | #systemctl status docker.service 26 | #sleep 5 27 | #systemctl enable docker.service 28 | 29 | # While you can run Docker as a root user, doing so is discouraged, 30 | # because of potential security risks and accidental modifications to your host system. 31 | # Instead, manage Docker operations under a non-root user account to enhance security. 32 | # sudo adduser $USER # Superuser 33 | # sudo useradd -m $USER -p userPASSWORD #dockeruser, -m create home directory -p password 34 | sudo usermod -aG docker $USER #dockeruser 35 | -------------------------------------------------------------------------------- /scripts/DoDoU.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Create a VM running Docker & Dockge for our stacks 3 | # Run as normal user in ~/ 4 | # wget https://github.com/nallej/MyJourney/raw/main/scripts/DoDoU.sh 5 | 6 | # Make the directory for oure stacks 7 | mkdir -p /home/$USER/docker/ 8 | # refresh and upgrade 9 | sudo apt update && sudo apt upgrade -y 10 | # Prerequisits 11 | sudo apt install -y apt-transport-https ca-certificates curl software-properties-common 12 | # GPG docker-archive-keyring 13 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg 14 | # Docker repository 15 | echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list >/dev/null 16 | # Houskeeping 17 | sudo apt update 18 | apt-cache policy docker-ce 19 | # Install Docker-ce, community edition and not the licenced one 20 | sudo apt install -y docker-ce 21 | 22 | # Add Dockge container 23 | sudo docker run -d -p 5001:5001 --name Dockge --restart=unless-stopped -v /var/run/docker.sock:/var/run/docker.sock -v /home/$USER/docker/dockge/data:/app/data -v /home/$USER/docker/stacks:/home/$USER/docker/stacks -e DOCKGE_STACKS_DIR=/home/$USER/docker/stacks louislam/dockge:latest 24 | 25 | # extra stuff 26 | #systemctl start docker.service 27 | #systemctl status docker.service 28 | #sleep 5 29 | #systemctl enable docker.service 30 | 31 | # While you can run Docker as a root user, doing so is discouraged, 32 | # because of potential security risks and accidental modifications to your host system. 33 | # Instead, manage Docker operations under a non-root user account to enhance security. 34 | # 35 | # sudo useradd -m $USER -p userPASSWORD #dockeruser, -m create home directory -p password 36 | # sudo adduser $USER sudo # Superuser 37 | sudo usermod -aG docker $USER #dockeruser 38 | -------------------------------------------------------------------------------- /scripts/K0s-starter.sh: -------------------------------------------------------------------------------- 1 | # Start setup os K0s Controller/Worker 2 | clear 3 | echo "" 4 | echo "Initialize the K0s Cluster" 5 | echo "" 6 | read -rp "Init the Controller [y/N] " x 7 | if [ "$x" = "y" ]; then 8 | #yes a Controller 9 | curl -sSLf https://get.k0s.sh | sudo sh 10 | sudo k0s install controller --enable-worker # or standalone 11 | sudo systemctl start k0scontroller.service 12 | sudo k0s token create --role worker --expiry 1h > k0s.token 13 | read -rp "IP worker 1: " IPworker1 14 | read -rp "IP worker 2: " IPworker2 15 | # ssh-keyscan -H $IPworker1 >> ~/.ssh/known_hosts 16 | # ssh-keyscan -H $IPworker2 >> ~/.ssh/known_hosts 17 | sudo scp k0s.token $USER@$IPworker1:/home/$USER 18 | sudo scp k0s.token $USER@$IPworker2:/home/$USER 19 | sudo k0s start 20 | sudo k0s status 21 | sudo k0s kubectl get nodes 22 | else 23 | # no on of the Workers 24 | curl -sSLf https://get.k0s.sh | sudo sh 25 | sudo k0s install worker --token-file k0s.token 26 | sudo k0s start 27 | sudo k0s status 28 | fi 29 | echo "" 30 | echo "After starting the Controller and all worker check status " 31 | echo " - sudo k0s kubectl get nodes" 32 | -------------------------------------------------------------------------------- /scripts/LynisInstall.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright (c) 2019-2024 CasaUrsus 3 | # Author: nalle (CasaUrsus) 4 | # License: MIT 5 | # https://github.com/nallej/MyJourne/raw/main/LICENSE 6 | 7 | 8 | sudo apt update && sudo apt install apt-transport-https gnupg2 -y 9 | # Download the key, 4 options 10 | #sudo wget -O - https://packages.cisofy.com/keys/cisofy-software-public.key | sudo apt-key add - 11 | #sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 013baa07180c50a7101097ef9de922f1c2fde6c4 12 | curl -fsSL https://packages.cisofy.com/keys/cisofy-software-public.key | sudo gpg --dearmor -o /etc/apt/trusted.gpg.d/cisofy-software-public.gpg 13 | #echo "deb [arch=amd64,arm64 signed-by=/etc/apt/trusted.gpg.d/cisofy-software-public.gpg] https://packages.cisofy.com/community/lynis/deb/ stable main" | sudo tee /etc/apt/sources.list.d/cisofy-lynis.list 14 | 15 | echo 'Acquire::Languages "none";' | sudo tee /etc/apt/apt.conf.d/99disable-translations 16 | 17 | echo "deb https://packages.cisofy.com/community/lynis/deb/ stable main" | sudo tee /etc/apt/sources.list.d/cisofy-lynis.list 18 | 19 | sudo apt update && sudo apt install lynis -y 20 | echo "..." 21 | sleep 1 22 | sudo apt-cache policy lynis 23 | echo "..." 24 | sudo lynis audit system --auditor $USER --logfile ~/LYNIS-initial-install.log 25 | -------------------------------------------------------------------------------- /scripts/MinSSDwear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### Extend the life of SSDs on a stand-alone Proxmox node 3 | # Run as root 4 | # wget https://github.com/nallej/MyJourney/raw/main/scripts/MinSSDwear.sh 5 | clear 6 | echo Copyright (c) 2022-$(date +%Y) CasaUrsus 7 | echo Author: nallej (CasaUrsus) 8 | echo License: MIT see @ https://github.com/nallej/MyJourney/raw/main/LICENSE 9 | echo 10 | 11 | ## No cluster stuff, see Proxmox docs and wiki 12 | systemctl disable --now pve-ha-lrm 13 | systemctl disable --now pve-ha-crm 14 | systemctl disable --now corosync.service 15 | 16 | ## Swappines added and set to 10, see Proxmox docs and wiki 17 | echo vm.swappines = 10 >> /etc/sysctl.conf 18 | 19 | ## Log2RAM from https://azlux.fr/ – via apt 20 | echo "deb [signed-by=/usr/share/keyrings/azlux-archive-keyring.gpg] http://packages.azlux.fr/debian/ bookworm main> 21 | wget -O /usr/share/keyrings/azlux-archive-keyring.gpg https://azlux.fr/repo.gpg 22 | apt update 23 | apt install log2ram 24 | systemctl restart log2ram 25 | 26 | systemctl status log2ram 27 | 28 | echo "See your logged data: journalctl -u log2ram -e" 29 | -------------------------------------------------------------------------------- /scripts/QuickLynis.sh: -------------------------------------------------------------------------------- 1 | git clone https://github.com/CISOfy/lynis 2 | cd lynis 3 | ./lynis audit system --quick 4 | -------------------------------------------------------------------------------- /scripts/README.md: -------------------------------------------------------------------------------- 1 | # Download a script 2 | #### Download a script: 3 | `wget https://github.com/nallej/MyJourney/raw/main/scripts/TheScriptName.sh` 4 | #### Make it executable: 5 | `chmod +x TheScriptName.sh or chmod 700 TheScriptName.sh` 6 | #### Run it: 7 | `./TheScriptName.sh` 8 | 9 | # Rice Proxmox login with figurine 10 | Make a bright welcome and a clear indication of **Node**, **Cluster** and **IP** 11 | 12 | ![image](https://github.com/user-attachments/assets/3cb82aa6-dff6-425a-a7de-a63e8c0d5ced) 13 | 14 | See https://homelab.casaursus.net/new_install/ 15 | 16 | # Template Builder 17 | The new version 5.0, is released 25.11.2023 but still in beta. 18 | This day the sunset is the last for some time, the sun rises next time 17 January, in the nortern part of our country. 19 | The latest version is 5.2 by 31.12.2023 20 | 21 | ![finished](https://github.com/nallej/MyJourney/assets/24981516/70d7fdec-88a2-4e2b-8bf0-6f33200b98c9) 22 | 23 | 24 | ## Name Change 25 | The myTemplateBuilder is now TemplateBuilder 26 | Both versions will be kept due to refrensing in blog posts 27 | 28 | ## Changes 29 | - **Dockge** Management app added to compete with Portainer 30 | - Added Non-Free versions Docker and Portainer-be 31 | - nala APT Front-End added 32 | - exa - ls as it should be 33 | - fzf fuzzy find 34 | - 2FA security 35 | - K0s cluster 36 | - K3s cluster 37 | - AlpineDocker Alpine as the Docker host 38 | - MyBash settings 39 | 40 | ![TB5 2](https://github.com/nallej/MyJourney/assets/24981516/30e1599d-1286-48e1-85bf-81e2f9f1ab5e) 41 | 42 | 43 | # NEWS 44 | ## Newest scrips 45 | - LynisInstall.sh For installing Lynis from apt 46 | - cpuVxSUPPORT.sh Check for x86-64-v2-4 support 47 | - MinSSDwear.sh Minimize SSD wear on a stand alone node 48 | - Create a VM running Docker and Dockge for our stacks 49 | - Debian based DoDoDeb.sh 50 | - Ubuntu based DoDoU.sh 51 | ## New scripts 52 | - figurine.sh Draw large colorfull hostnames at login. Uses the figurine package, download and extract 53 | - wolstart 54 | - wolstart - to be used as a command 55 | - wolstart.sh - use as a script 56 | - my.wol.nodes - a list of nodes, used to copy into the script 57 | -------------------------------------------------------------------------------- /scripts/StopDelCorosync.sh: -------------------------------------------------------------------------------- 1 | # Stop the corosync and the pve-cluster services on the node: 2 | # wget https://github.com/nallej/MyJourney/raw/main/StopDelCorosync.sh 3 | 4 | systemctl stop pve-cluster 5 | systemctl stop corosync 6 | 7 | # Start the cluster filesystem again in local mode: 8 | pmxcfs -l 9 | 10 | # Delete the corosync configuration files: 11 | rm /etc/pve/corosync.conf 12 | rm -r /etc/corosync/* 13 | 14 | # Start the filesystem again as normal service: 15 | 16 | killall pmxcfs 17 | systemctl start pve-cluster 18 | 19 | # Remove any left over .conf files 20 | echo "" 21 | echo "" 22 | echo "Remove any *.conf left in /etc/pve/qemu-server" 23 | echo "Remove any *.conf left in /etc/pve/lxc" 24 | echo "Remove any *.conf left in /etc/pve/nodes//qemu-server" 25 | echo "Remove any *.conf left in /etc/pve/nodes//lxc" 26 | echo "" 27 | echo "Remove ghost of old node can be removed from /etc/pve/corosync.conf" 28 | echo "" 29 | # 30 | # Browser errors 31 | # You can maybe fix it by: 32 | # rm remove /etc/pve/priv/pve-root-ca.key /etc/pve/pve-root-ca.pem 33 | # rm /etc/pve/local/pve-ssl.pem /etc/pve/local/pve-ssl.key /etc/pve/local/pveproxy-ssl.pem /etc/pve/local/pveproxy-ssl.key (on each node!) 34 | # run pvecm updatecerts 35 | # run systemctl restart pveproxy 36 | # 37 | # Now the GUI should work again, with the default self-signed certificates. 38 | # In the GUI or 'pvenode' upload your certificate + key 39 | # (it will be stored in '/etc/pve/local/pveproxy-ssl.pem' / '/etc/pve/local/pveproxy-ssl.key' 40 | -------------------------------------------------------------------------------- /scripts/aplineInstallNFS.sh: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /scripts/compareFiles.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | echo 3 | echo "Compare File 1 to File 2" 4 | 5 | echo "File 1 = /home/nalle/bigfile.txt" 6 | echo "File 2 = /home/nalle/backup/bigfile.txt.old" 7 | echo 8 | read -p "File 1: " file1 9 | read -p "File 2: " file2 10 | 11 | 12 | 13 | if cmp -s "$file1" "$file2"; then 14 | printf 'The file "%s" is the same as "%s"\n' "$file1" "$file2" 15 | else 16 | printf 'The file "%s" is different from "%s"\n' "$file1" "$file2" 17 | fi 18 | -------------------------------------------------------------------------------- /scripts/cpuVxSUPPORT.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh -eu 2 | #Check for x86-64-v2, v3, v4 support 3 | 4 | flags=$(cat /proc/cpuinfo | grep flags | head -n 1 | cut -d: -f2) 5 | 6 | supports_v2='awk "/cx16/&&/lahf/&&/popcnt/&&/sse4_1/&&/sse4_2/&&/ssse3/ {found=1} END {exit !found}"' 7 | supports_v3='awk "/avx/&&/avx2/&&/bmi1/&&/bmi2/&&/f16c/&&/fma/&&/abm/&&/movbe/&&/xsave/ {found=1} END {exit !found}"' 8 | supports_v4='awk "/avx512f/&&/avx512bw/&&/avx512cd/&&/avx512dq/&&/avx512vl/ {found=1} END {exit !found}"' 9 | 10 | echo "No x86-64-v2 -3 -4 support" 11 | 12 | echo -e "\e[1A\e[K$flags" | eval $supports_v2 || exit 2 && echo -e "\e[1A\e[KYour CPU supports x86-64-v2" 13 | echo -e "\e[1A\e[K$flags" | eval $supports_v3 || exit 3 && echo -e "\e[1A\e[KYour CPU supports x86-64-v3" 14 | echo -e "\e[1A\e[K$flags" | eval $supports_v4 || exit 4 && echo -e "\e[1A\e[KYour CPU supports x86-64-v4" 15 | -------------------------------------------------------------------------------- /scripts/debInstallNFS.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Setup a NFS Server 3 | 4 | clear 5 | 6 | # Init Variables 7 | initSUB=10.10.40.0 8 | initSRV=10.10.40.40 9 | dirNAME=139 # Last Octet of SRV IP 10 | 11 | # No EDIT beyound thtis point =============================================== # 12 | 13 | # Functions ------------------------------------------------------------------# 14 | 15 | function setroot() { # Function I am root or not 16 | if [[ "$EUID" = 0 ]]; then 17 | echo -e "\nInitialaizing:" # I am root 18 | else 19 | sudo -k 20 | if sudo true; then # Correct password 21 | clear 22 | echo -e "\nStart My Code what ever it's" 23 | echo -e "\nInitialaizing..." 24 | else 25 | echo "wrong password!" 26 | exit #exit if 3 times wrong 27 | fi 28 | fi 29 | } 30 | 31 | function serverNFS() { # setting up the NFS-Server 32 | sudo mkdir -p /exports/{backup,documents,films,music,photos} 33 | sudo apt-get update && sudo apt-get -y install nfs-kernel-server 34 | sudo cp /etc/exports /etc/exports.orig 35 | sudo sh -c "echo '/exports/backup $srvIP/255.255.255.0(rw,no_subtree_check) # subnets allowed' >> /etc/exports" 36 | sudo sh -c "echo '/exports/documents $srvIP/255.255.255.0(rw,no_subtree_check) # subnets allowed' >> /etc/exports" 37 | sudo sh -c "echo '/exports/films $srvIP/255.255.255.0(rw,no_subtree_check) # subnets allowed' >> /etc/exports" 38 | sudo sh -c "echo '/exports/music $srvIP/255.255.255.0(rw,no_subtree_check) # subnets allowed' >> /etc/exports" 39 | sudo sh -c "echo '/exports/photos $srvIP/255.255.255.0(rw,no_subtree_check) # subnets allowed' >> /etc/exports" 40 | sudo systemctl restart nfs-kernel-server 41 | sudo systemctl status nfs-kernel-server 42 | echo "You might need to reboot for the NFS Server for it to work" 43 | } 44 | 45 | function clientNFS() { 46 | # Setting up a NFS-Server Client --- EDIT befor running script --- 47 | sudo apt-get update && sudo apt-get -y install nfs-common autofs 48 | sudo apt-get -y install autofs 49 | # EDIT 139 should be the last octet of the server 50 | mkdir /srv/nfs/$dirNAME/ 51 | echo "/srv/nfs/$dirNAME/ /etc/auto.nfs --ghost --timeout=60" >> /etc/auto.master 52 | echo "backup -fstype=nfs4,rw $cliIP:/exports/backup" >> /etc/auto.nfs 53 | echo "documents -fstype=nfs4,rw $cliIP:/exports/documents" >> /etc/auto.nfs 54 | echo "films -fstype=nfs4,rw $cliIP:/exports/films" >> /etc/auto.nfs 55 | echo "music -fstype=nfs4,rw $cliIP:/exports/music" >> /etc/auto.nfs 56 | echo "photos -fstype=nfs4,rw $cliIP:/exports/photos" >> /etc/auto.nfs 57 | sudo systemctl restart autofs 58 | } 59 | 60 | 61 | setroot 62 | # M A I N C O D E section ==================================================# 63 | backt="setupNFS.sh is part of the My HomeLab Journey Project" # Background text 64 | 65 | if whiptail --backtitle "$backTEXT" --title "Create a NFS Server or a NFS Client" --yesno "Install a Server or a Client " 10 68 --no-button "Server" --yes-button "Client"; then 66 | srvIP=$(whiptail --backtitle "$backTEXT" --title "Create NFS Client" --inputbox "Server IP" 10 58 $initSRV 3>&1 1>&2 2>&3) 67 | clientNFS 68 | else 69 | subIP=$(whiptail --backtitle "$backTEXT" --title "Create NFS Server" --inputbox "Subnet" 10 58 $initSUB 3>&1 1>&2 2>&3) 70 | serverNFS 71 | fi 72 | -------------------------------------------------------------------------------- /scripts/figurine.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #scp figurine root@192.0.2.41:/usr/local/bin 3 | #scp figurine.sh root@192.0.2.41:/etc/profile.d/ 4 | echo "" #starwars, Stampranello, Contessa Contrast, Mini, Shadow 5 | /usr/local/bin/figurine -f "starwars.flf" 10.10.110.43 6 | echo "" 7 | echo "" 8 | /usr/local/bin/figurine -f "3d.flf" Pve - 3.lab 9 | echo "" 10 | -------------------------------------------------------------------------------- /scripts/initPVE.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Download: wget https://github.com/nallej/MyJourney/raw/main/scripts/PveInit.sh 3 | clear 4 | echo "This script will add my personal preferenses to Proxmox nodes" 5 | echo " Adding apps" 6 | echo " - bat, cat on steroids" 7 | echo " - exa, ls as a modern app" 8 | echo " - nala, apt frontend with a modern look" 9 | read -rp "Install the set [y/N]: " ben 10 | [[ "$ben" == 'yY ]] && apt update && apt install -y bat exa nala 11 | 12 | # Adding aliases to your bash and a new prompt 13 | echo "Add aliases or change the bash commands with aliases" 14 | read -rp "Install bash_aliases [y/N]: " ali 15 | [[ "$ali" == 'yY' ]] && wget https://github.com/nallej/MyJourney/raw/main/.bash_aliases 16 | # And also the personal bash prompt 17 | echo " Implove the bash prompl [y/N]: " pro 18 | [[ "$pro" == 'yY' ]] && wget https://github.com/nallej/MyJourney/raw/main/.bash_prompt 19 | 20 | # Activate the changes 21 | # Adding bash_aliases to bashrc. Usually not needed 22 | echo "[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases" >> .bashrc 23 | echo "Edit your new bash: nano .bash_aliases - and make it yours" 24 | echo " - change the IP mask if yours not [ /24 ] in [ alias myip ]" 25 | echo " - add any other alias you like" 26 | echo " - remove what you do not like" 27 | #echo " - exit from bat type q" 28 | 29 | echo "To start using the new bash, type: . .bash_aliases (note the periods)" 30 | echo #chmod 700 .initPVE.sh# 31 | echo ". .initPVE.sh" 32 | echo ". .bash_aliases" 33 | read -rp "Start using new settings [y/Y] " sta 34 | [[ "$sta" == 'yY' ]] && source .bash_aliases 35 | -------------------------------------------------------------------------------- /scripts/initVM.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Download: wget https://github.com/nallej/MyJourney/raw/main/scripts/initVM.sh 3 | clear 4 | echo "This script will add my personal preferenses to Proxmox nodes" 5 | echo "Switch keyboard sudo nano /etc/default/keyboard" 6 | sudo nano /etc/default/keyboard 7 | #echo "Add bat, exa and nala" 8 | # apt update && apt install -y bat exa nala 9 | echo "Adding aliases to your bash and a new prompt" 10 | #wget https://github.com/nallej/MyJourney/raw/main/.bash_aliases 11 | wget https://github.com/nallej/MyJourney/raw/main/.bash_aliases -O .bash-personal 12 | wget https://github.com/nallej/MyJourney/raw/main/.bash_prompt 13 | echo "Activating the changes" 14 | # - Adding bash_aliases to .bashrc" 15 | # echo "[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases" >> .bashrc 16 | echo " - Adding bash-personal to bashrc and activate" 17 | echo "[[ -f ~/.bash-personal ]] && . ~/.bash-personal" >> .bashrc 18 | echo "Start using the new bash, type: . .bashrc (note the periods)" 19 | . .bashrc 20 | -------------------------------------------------------------------------------- /scripts/my.wol.nodes: -------------------------------------------------------------------------------- 1 | NAS-1,192.0.2.40,00:11:22:33:44:55 2 | Pve-1,192.0.2.41,00:11:22:33:44:55 3 | Pve-2,192.0.2.42,00:11:22:33:44:55 4 | Pve-3,192.0.2.43,00:11:22:33:44:55 5 | Pve-4,192.0.2.44,00:11:22:33:44:55 6 | Pve-5,192.0.2.45,00:11:22:33:44:55 7 | Pve-6,192.0.2.46,00:11:22:33:44:55 8 | Pve-7,192.0.2.47,00:11:22:33:44:55 9 | Pve-8,192.0.2.48,00:11:22:33:44:55 10 | Pve-9,192.0.2.49,00:11:22:33:44:55 11 | -------------------------------------------------------------------------------- /scripts/myTemplateBuilder.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | #-----------------------------------------------------------------------------# 4 | # For more info see: https://pve.proxmox.com/pve-docs/qm.conf.5.html # 5 | # Date format and >>>> ---- <<<< **** for easy sorting # 6 | #-----------------------------------------------------------------------------# 7 | 8 | # Install this script by: 9 | # - open a terminal in the Proxmox node as root 10 | # - run wget https://github.com/nallej/MyJourney/raw/main/myTemplateBuilder.sh 11 | # - chmod 700 myTemplateBuilder.sh 12 | # 13 | 14 | # Edit the script is very important: 15 | # - set memory size 16 | # - # of cores 17 | # - what apps do you need 18 | # - VM settings 19 | # - place of key 20 | # or upload your puplic key to use for auto creation to: 21 | # - ~/.ssh/my_key 22 | 23 | # This script generate a workin VM or a Template or a set of VMs 24 | # The functionallity is detemend by your Y/N answers 25 | 26 | # Global Functions ===========================================================# 27 | 28 | c-info() { 29 | clear 30 | cat <<"EOF" 31 | 32 | Copyright (c) 2021-2023 CasaUrsus 33 | Author: nallej (CasaUrsus) 34 | License: MIT 35 | https://github.com/nallej/MyJourney/raw/main/LICENSE 36 | 37 | myTempBuilder.sh 38 | Part of the MyJourney project @ homelab.casaursus.net 39 | - https://homelab.casaursus.net/proxmox-automation 40 | - https://homelab.casaursus.net/setting-up-kubernetes-k8s 41 | 42 | Version History: 43 | Version 1.0 29.11.2022 v1.1 01.12.2022 44 | version 2.0 04.01.2023 v2.1 09.01.2023 v2.2 29.01.2023 45 | version 3.0 30.05.2023 v3.1 31.05.2023 v3.2 01.06.2023 v3.3 12.10.2023 46 | version 4.0 12.10.2023 47 | 48 | EOF 49 | } 50 | 51 | header() { 52 | clear 53 | cat <<"EOF" 54 | 55 | ____ _ _ 56 | / ___|__ _ ___ __ _| | | |_ __ ___ _ _ ___ 57 | | | / _` / __|/ _` | | | | '__/ __| | | / __| 58 | | |__| (_| \__ \ (_| | |_| | | \__ \ |_| \__ \ 59 | \____\__,_|___/\__,_|\___/|_| |___/\__,_|___/ 60 | 61 | 62 | EOF 63 | } 64 | 65 | useColors() # Function: define colors to be used 66 | { 67 | # color code color as bold 68 | red=$'\e[31m'; redb=$'\e[1;31m' # call red with $red and bold as $redb 69 | grn=$'\e[32m'; grnb=$'\e[1;32m' # call as green $grn as bold green $grnb 70 | yel=$'\e[33m'; yelb=$'\e[1;33m' # call as yellow $yel as bold yellow $yelb 71 | blu=$'\e[34m'; blub=$'\e[1;34m' # call as blue $blu as bold blue $blub 72 | mag=$'\e[35m'; magb=$'\e[1;35m' # call as magenta $mag as bold magenta $magb 73 | cyn=$'\e[36m'; cynb=$'\e[1;36m' # call as cyan $cyn as cyan bold $cynb 74 | end=$'\e[0m' 75 | 76 | #Use them to print with colours: printf "%s\n" "Text in white ${blu}blue${end}, white and ${mag}magenta${end}." 77 | } 78 | 79 | spinner() # Function: display a animated spinner 80 | { 81 | # The different Spinner Arrays to choose from 82 | local array1=("◐" "◓" "◑" "◒") 83 | local array2=("░" "▒" "▓" "█") 84 | local array3=("╔" "╗" "╝" "╚") 85 | local array4=("┌" "┐" "┘" "└") 86 | local array5=("▄" "█" "▀" "█") 87 | local array6=('-' '\' '|' '/') # L to R 88 | local array7=('-' '/' '|' '\') # R to L 89 | local array9=("⠋" "⠙" "⠹" "⠸" "⠼" "⠴" "⠦" "⠧" "⠇" "⠏") 90 | 91 | local delays=0.1 # Delay between each characte 92 | 93 | tput civis # Hide cursor and spinn 94 | 95 | while :; do 96 | for character in "${array9[@]}"; do # Use this Array 97 | printf "%s" "$character" 98 | sleep "$delays" 99 | printf "\b" # Move cursor back 100 | done 101 | done 102 | } 103 | 104 | # Local Functions ========================================# 105 | 106 | guestfs() # Function: install the libguestfs-tools 107 | { 108 | apt-get update 109 | apt-get install -y libguestfs-tools 110 | } 111 | 112 | getUbuntu() # Function: get a Cloud Image, Ubuntu as example, CIs are allway up to date 113 | # It's a .qcow2 fil with the extension .img - we turn it back to .qcow2 114 | { 115 | if [[ $mini == [yY] ]]; then 116 | if [[ -f "mini.qcow2" && $upd == [yY] ]]; then 117 | cp mini.qcow2 base.qcow2 118 | else 119 | wget -O mini.qcow2 https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img 120 | cp mini.qcow2 base.qcow2 121 | fi 122 | else 123 | if [[ -f std.qcow2 && $upd == [yY] ]]; then 124 | cp std.qcow2 base.qcow2 125 | else 126 | wget -O std.qcow2 https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64-disk-kvm.img 127 | cp std.qcow2 base.qcow2 128 | fi 129 | fi 130 | } 131 | 132 | createBase() # Function: create a fully loaded base ISO ### Set the Disk size ### set the apps needed #### 133 | # Add QEMU Guest Agent and any other packages you’d like in your base image. 134 | # libguestfs-tools has to be installed on the node! 135 | # Add or delete functionallity according to your needs 136 | # virt-customize -a /path/to/your/vm-image.qcow2 --firstboot /path/to/your/firstboot-script.sh 137 | # virt-customize -a base.qcow2 --firstboot.sh 138 | { 139 | qemu-img resize base.qcow2 $ds #16G is typical - Resize the disk to your needs, 8 - 32G is normal 140 | # Add QEMU Guest Agent and any other packages you’d like in your base image. 141 | # libguestfs-tools has to be installed on the node. 142 | # Add or delete according to your needs 143 | if [[ $o1 == [yY] ]]; then virt-customize -a base.qcow2 --install qemu-guest-agent ; fi # o1 Highly recommended 144 | if [[ $o2 == [yY] ]]; then virt-customize -a base.qcow2 --install nano,ncurses-term ; fi # o2 I like it 145 | if [[ $o3 == [yY] ]]; then virt-customize -a base.qcow2 --install git ; fi # o3 moustly needed 146 | if [[ $o4 == [yY] ]]; then virt-customize -a base.qcow2 --install unattended-upgrades ; fi # o4 good feature 147 | if [[ $o5 == [yY] ]]; then virt-customize -a base.qcow2 --install fail2ban ; fi # o5 highly recommended 148 | if [[ $o6 == [yY] ]]; then virt-customize -a base.qcow2 --install clamav,clamav-daemon ; fi # o6 highly recommended 149 | if [[ $o7 == [yY] ]]; then virt-customize --install mailutils -a base.qcow2; fi # o7 might be needed 150 | if [[ $o8 == [yY] ]]; then 151 | #virt-customize -a base.qcow2 --firstboot-command 'sudo apt-get update' 152 | virt-customize -a base.qcow2 --install containerd,curl,software-properties-common 153 | # virt-customize -a base.qcow2 --firstboot-command 'sudo apt-get install software-properties-common' 154 | virt-customize -a base.qcow2 --firstboot-command 'sudo apt-get update' 155 | virt-customize -a base.qcow2 --firstboot-command 'curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | gpg --dearmor | sudo dd status=none of=/usr/share/keyrings/kubernetes-archive-keyring.gpg' 156 | virt-customize -a base.qcow2 --firstboot-command 'echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list' 157 | #virt-customize -a base.qcow2 --firstboot-command 'sudo apt-get update && sudo apt-get upgrade' 158 | virt-customize -a base.qcow2 --firstboot-command 'sudo swapoff -a' 159 | virt-customize -a base.qcow2 --mkdir /etc/containerd 160 | virt-customize -a base.qcow2 --firstboot-command 'containerd config default | sudo tee /etc/containerd/config.toml' 161 | virt-customize -a base.qcow2 --firstboot-command 'echo "br_netfilter" > /etc/modules-load.d/k8s.conf' 162 | virt-customize -a base.qcow2 --firstboot-command 'sed -i "s/^\( *SystemdCgroup = \)false/\1true/" /etc/containerd/config.toml' 163 | virt-customize -a base.qcow2 --firstboot-command 'sed -i -e "/#net.ipv4.ip_forward=1/c\net.ipv4.ip_forward=1" etc/sysctl.conf' 164 | virt-customize -a base.qcow2 --firstboot-command 'sudo apt-get update && sudo apt install -y kubeadm kubectl kubelet' 165 | virt-customize -a base.qcow2 --firstboot-command 'sudo truncate -s 0 /etc/machine-id' 166 | virt-customize -a base.qcow2 --firstboot-command 'sudo rm /var/lib/dbus/machine-id' 167 | virt-customize -a base.qcow2 --firstboot-command 'sudo ln -s /etc/machine-id /var/lib' 168 | fi 169 | } 170 | 171 | createVM() # Funtion: creat a VM or a Template using a CI #### EDIT THE DEFAULTS #### 172 | { 173 | # Choose RAM, Disk size, # of cores, what bridge to use. virtio is mandatory 174 | if [[ $mini == [yY] ]]; then 175 | if [[ $tname < ' ' ]]; then tname='ubuntu-mini'; fi 176 | else 177 | if [[ $tname < ' ' ]]; then tname='ubuntu-std'; fi 178 | fi 179 | # if [[ $tno < 1 ]]; then tno=8000; fi 180 | # if [[ $ms < 1 ]]; then ms=1024; fi 181 | # if [[ $cc < 1 ]]; then cc=1; fi 182 | # if [[ $vmbr < 9 ]]; then vmbr="vmbr2"; fi 183 | # if [[ $storage < ' ' ]]; then storage="tank"; fi 184 | 185 | # Creare the base image ----------------------------------------------# 186 | 187 | ibase="$tno --memory $ms --core $cc --name $tname --net0 virtio,bridge=$vmbr" 188 | if [[ tag > 0 ]]; then ibase="${ibase},tag=$vlan"; fi 189 | qm create $ibase 190 | echo "Base created: $ibase" 191 | # Set options --------------------------------------------------------# 192 | 193 | qm importdisk $tno base.qcow2 $storage # Import the disc to the base of the template. Where to put the VM local-lvm 194 | qm set $tno --scsihw virtio-scsi-pci --scsi0 $storage:vm-$tno-disk-0 # Attache the disk to the base of the template 195 | qm set $tno --ide2 $storage:cloudinit # Attach the cloudinit file - you might need to EDIT it later ! 196 | qm set $tno --boot c --bootdisk scsi0 # Make the cloud init drive bootable and only boot from this disk 197 | qm set $tno --serial0 socket --vga serial0 # Add serial console, to be able to see console output! 198 | qm set $tno --onboot 1 # Autostart vm at boot - default is 0 - Ususlly most VM's are allway running 199 | qm set $tno --agent 1 # Use Qemu Guest Agent - default is 0 200 | qm set $tno --ostype l26 # Set OS type Linux 5.x kernel 2.6 - default is other 201 | qm set $tno --ipconfig0 ip="dhcp" # Set dhcp on 202 | qm set $tno --ciuser $ciu # "admin" use your imagination 203 | qm set $tno --cipassword $cip # "Pa$$w0rd" use a super complicated one 204 | qm set $tno --discard=on # Enable Thin-provisioning 205 | # Tuning see: 206 | # https://forum.proxmox.com/threads/proxmox-ve-7-2-benchmark-aio-native-io_uring-and-iothreads.116755/ 207 | # https://kb.blockbridge.com/technote/proxmox-aio-vs-iouring/ 208 | #qm set $tno --ssd=1 # SSD emulation 209 | #qm set $tno --iothread=1 # iothreads tuning 210 | #qm set $tno --aio=native # aio tuning 211 | #qm set $tno --aio=io_uring # aio tuning 212 | if [[ $my_key == [yY] ]]; then qm set $tno --sshkey ~/.ssh/my_key; fi # sets the users key to the vm 213 | 214 | ## More automation can be added to cloud-init, examples below ------------# 215 | # 1. copy your public key to the node or copy it later to the VM 216 | #ssh-copy-id -i ~/.ssh/id_ed25519 username@pve.lab.example.com 217 | 218 | # 2. use a bootstrap file at the initial boot that can have snippets. 219 | # You need to check the status of the Storage Manager and set according to yours 220 | # pvesm status 221 | # pvesm set local --content backup,iso,snippets,vztmpl 222 | # qm set $tno --cicustom "vendor=:snippets/vendor.yaml" 223 | } 224 | 225 | createTemplate() # Function: Create the template ex. 9000 226 | { 227 | if [[ $tok == [yY] ]]; then qm template $tno; fi 228 | sleep .5 229 | } 230 | 231 | createClones() # Function: Cloning the template 232 | { 233 | if [[ $ctno -gt 0 ]]; then 234 | x=0 235 | while [ $x -lt $ctno ] 236 | do 237 | xx=$(($fcno + $x)) 238 | x=$(( $x + 1 )) 239 | qm clone $tno $xx --name $cname$x --full 240 | done 241 | fi 242 | } 243 | 244 | # Code Section ===============================================================# 245 | useColors # Use color codes 246 | clear # Clear the screan 247 | 248 | #Init the log 249 | echo ">>>> Started the Install @ $(date +"%F %T") **** ****" > ~/installMTB.log 250 | printf ${blub} 251 | c-info 252 | sleep 2 253 | # Main Script ================================================================# 254 | printf ${yelb} 255 | header 256 | # Main menu ------------------------------------------------------------------# 257 | echo -e "${magb}This script will create Templates and or VM's on your node.${end}" 258 | echo " " 259 | echo -e "${redb}NOTE${end} - libguestfs-tools is needed. Pls installe it on this node" 260 | echo -e "${cyn}" 261 | echo " Remember to edit the script before executing: " 262 | echo " - basic settings are 1 core and 1024M RAM" 263 | echo " - normal disk size for a VM is 8-16G or sometimes 32G" 264 | echo " - Enter Disk size as ${redb}8G${end}${cyn} NOT 8 !" 265 | echo -e " - OS = L26, IP = DHCP, QGA = on, Autostart = off ${end}" 266 | echo " " 267 | echo -e "${yelb}Start the configuration${end}" 268 | read -rp " Install the libguestfs-tools Now [y/N] : " gfs 269 | echo -e "${yelb} options:${end}" 270 | read -rp " - qemu-guest-agent [y/N] : " o1 271 | read -rp " - nano editor, ncurses-term [y/N] : " o2 272 | read -rp " - git [y/N] : " o3 273 | read -rp " - unattended-upgrades [y/N] : " o4 274 | read -rp " - fail2ban [y/N] : " o5 275 | read -rp " - clamav, clamav-daemon [y/N] : " o6 276 | read -rp " - mailutils [y/N] : " o7 277 | read -rp " - make K8s settings [y/N] : " o8 278 | echo -e "${magb} Creating the Base Image from a Cloud image${end}" 279 | read -rp " - Use the minimal Ubuntu image [y/N] : " mini 280 | read -rp " - Use existing ISO-image [y/N] : " upd 281 | read -rp " - Disk size (8, 16 or 32G) e.g 8G : " ds 282 | read -rp " - Memory (1024 is plenty) e.g. 1024 : " ms 283 | read -rp " - Core count (1 is plenty) e.g. 1 : " cc 284 | read -rp " - Set vmbr to be used e.g. vmbr2 : " vmbr 285 | read -rp " - Set vlan tag e.g. 0=no : " vlan 286 | echo -e "${magb} Settings for the VM or Template and VMs${end}" 287 | read -rp " - Set VM or Template ID e.g. 9000 : " tno 288 | read -rp " - Set VM or Template name e.g. mini : " tname 289 | read -rp " - Storage to use VM e.g. local-zfs : " storage 290 | read -rp " - Create with CI user e.g. admin : " ciu 291 | echo -n " - " 292 | cip="$(systemd-ask-password "Enter the password:")" 293 | read -rp " - set key from ~/.ssh/my_key [y/N] : " my_key 294 | echo -e "${magb} Settings for Template and VMs${end}" 295 | read -rp " - Create as a Template id $tno [y/N] : " tok 296 | 297 | if [[ $tok == [yY] ]]; then 298 | read -rp " - Create # clones of $tno 0=no clones: " ctno 299 | if [[ $ctno -gt 0 ]]; then 300 | read -rp " - ID number for first clone 5000 : " fcno 301 | if [ $ctno = 1 ]; then 302 | xz=$fcno 303 | else 304 | xz=$(($fcno + $ctno)) 305 | fi 306 | read -rp " - name of clone's node1 to node$ctno : " cname 307 | echo -e "${yelb} Creating Template with ID $tno, $ds" 308 | echo " - creating cloned VM's $fcno - $xz" 309 | y=1 310 | echo -e " - named as $cname$y - $cname$ctno${end}" 311 | fi 312 | else 313 | echo "" 314 | echo -e "${yelb} - Creating a VM${end} $tname ${yelb}with ID${end} $tno ${yelb}Disk ${end}$ds" 315 | fi 316 | echo "" 317 | read -rp "${redb}Start the Install [y/N] : ${end}" ok 318 | echo "" 319 | # end of menu ----------------------------------------------------------------# 320 | 321 | # init log 322 | if [[ $ok == [yY] ]]; then 323 | # Run the spinner in the background and Save the PID 324 | spinner & 325 | spinner_pid=$! 326 | 327 | # Execute the functions --------------------------------------------------# 328 | if [[ $gfs == [yY] ]]; then 329 | (guestfs >> ~/installMTB.log 2>&1) 330 | printf "\b \n" 331 | echo "${grn} ✔${end}Installed libguestfs-tools" 332 | echo "---- * libguestfs-tools loaded @ $(date +"%F %T") **** ****" >> ~/installMTB.log 333 | fi 334 | sleep .5 335 | 336 | echo "---->> Cloud Image creation @ $(date +"%F %T") **** ****" >> ~/installMTB.log 337 | (getUbuntu >> ~/installMTB.log 2>&1) 338 | printf "\b" 339 | echo "${grn} ✔${end} Cloud Image downloaded" 340 | echo "---- * Cloud Image downloaded @ $(date +"%F %T") **** ****" >> ~/installMTB.log 341 | 342 | echo "---->> create base $ds image @ $(date +"%F %T") **** ****" >> ~/installMTB.log 343 | (createBase >> ~/installMTB.log 2>&1) 344 | printf "\b" 345 | echo "${grn} ✔${end} base.qcow2 image created" 346 | echo "---- * base.qcow2 $ds done @ $(date +"%F %T") **** ****" >> ~/installMTB.log 347 | 348 | echo "---->> VM start create $(date +"%F %T") **** ****" >> ~/installMTB.log 349 | (createVM >> ~/installMTB.log 2>&1) 350 | printf "\b" 351 | echo "${grn} ✔${end} VM created, $tno-$tname" 352 | echo "---- * VM Created $(date +"%F %T") **** ****" >> ~/installMTB.log 353 | 354 | if [[ $tok == [yY] ]]; then 355 | echo "---->> Template creation @ $(date +"%F %T") **** ****" >> ~/installMTB.log 356 | createTemplate &> /dev/null 357 | printf "\b" 358 | echo "${grn} ✔${end} Template created, $tno-$tname" 359 | echo "---- * Template created @ $(date +"%F %T") **** ****" >> ~/installMTB.log 360 | 361 | fi 362 | if [[ $ctno -gt 0 ]]; then 363 | echo "---->> Clones creation start @ $(date +"%F %T") **** ****" >> ~/installMTB.log 364 | createClones &> /dev/null 365 | printf "\b" 366 | echo "${grn} ✔${end} Clone(s) created" 367 | echo "---- * Clones created @ $(date +"%F %T") **** ****" >> ~/installMTB.log 368 | fi 369 | # End of Execute Functions------------------------------------------------# 370 | echo "<<<< Install ended OK @ $(date +"%F %T") **** ****" >> ~/installMTB.log 371 | 372 | # Terminate the Spinner 373 | kill "$spinner_pid" 374 | wait "$spinner_pid" 2>/dev/null 375 | 376 | # End messages 377 | if [[ $ctno -gt 0 ]]; then 378 | echo "" 379 | echo "Log created: ~/installMTB.log - check for errors" 380 | echo "" 381 | else 382 | echo "" 383 | #tput setaf 3 384 | #echo "Remember do NOT start the VM before making it into a template !" 385 | #tput sgr0 386 | #echo "Edit the Cloud-Init NOW ... then clone your VM's" 387 | #tput setaf 1 388 | #echo "" 389 | #echo "WARNING - Do NOT start the VM - WARNING" 390 | #tput sgr0 391 | # Alt way of output 392 | #useColors 393 | printf "%s\n" "Remember do ${red}NOT${end} to start the VM before making it into a template !" 394 | printf "%s\n" "Edit the Cloud-Init ${red}NOW${end} ... then clone your VM's" 395 | echo 396 | printf "%s\n" "${red}WARNING${end} - Do ${red}NOT${end} start the VM - ${red}WARNING${end}" 397 | sleep 1 398 | echo "" 399 | echo "Log created: ~/installMTB.log - Check for errors" 400 | echo "" 401 | fi 402 | sleep 2 403 | else 404 | echo "<<<< Exited the Install @ $(date +"%F %T") **** ****" >> ~/installMTB.log 405 | fi 406 | # Show the Cursor Again 407 | tput cnorm 408 | 409 | read -rp "Print the log [Y/n] : " pl 410 | if [[ $pl == [yY] ]]; then cat ~/installMTB.log; fi 411 | -------------------------------------------------------------------------------- /scripts/newBashAddon: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # wget https://github.com/nallej/MyJourney/raw/main/newBashAddon.sh 4 | # ---------------------------------------- # 5 | # Edit the script according to your needs! # 6 | # ---------------------------------------- # 7 | 8 | clear 9 | echo "This script will add my personal preferenses to Proxmox nodes" 10 | echo "" 11 | 12 | echo " Adding bat exa (cat and ls on steroids) to your system" 13 | apt-get update >addon.log 2>&1 14 | apt-get install -y bat exa >>addon.log 2>&1 15 | #apt-get install -y iperf3 ethtool net-tools etherwake hwinfo lm-sensors i2c-tools btop tshark >>addon.log 2>&1 16 | echo "Adding Fail2ban security enhansment" 17 | # Add Fail2ban security enhancement to this node 18 | apt-get update && apt-get install fail2ban -y >>addon.log 2>&1 19 | 20 | # security audis with lynis https:// 21 | # git clone https://github.com/CISOfy/lynis 22 | 23 | echo " Adding aliases to your bash and a new prompt" 24 | # Add to or change the bash commands 1>>$ok_log 2>>$ei_log 25 | wget https://github.com/nallej/MyJourney/raw/main/.bash_aliases >>addon.log 2>&1 26 | # And also the personal bash prompt 27 | wget https://github.com/nallej/MyJourney/raw/main/.bash_prompt >>addon.log 2>&1 28 | 29 | # Activate the changes 30 | echo "" 31 | echo "" 32 | echo " Adding bash_aliases to bashrc" 33 | echo "alias ls=exa" >> .bashrc 34 | echo "alias ll='ls -l'" >> .bashrc 35 | echo "alias l='ls -la'" >> .bashrc 36 | echo "[[ -f ~/.bash_aliases ]] && . ~/.bash_aliases" >> .bashrc 37 | 38 | echo echo "Personized aliases added" >>addon.log 2>&1 39 | echo "" 40 | echo "Edit your new bash by nano .bash_aliases and make it yours" 41 | echo " - change the IP mask if not /24 in [alias myip]" 42 | echo " - add any alias you like" 43 | echo " - comment out what you do not like" 44 | echo " - exit from bat type q" 45 | echo " To start using the new bash, type: . .bash_aliases (note the periods)" 46 | 47 | source .bash_aliases 48 | -------------------------------------------------------------------------------- /scripts/wolstart: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Data Section Arrays and variables ==========================================# 4 | macArray=(); ipArray=(); nameArray=(); statusArray=();startArray=() 5 | nic=false; byf=false; byn=false; err=0; wolFile=""; nodes=0 # Tally on nodes 6 | 7 | nodeData="NAS-1,192.0.2.40,00:11:22:33:44:55 8 | Pve-1,192.0.2.41,00:11:22:33:44:55 9 | Pve-2,192.0.2.42,00:11:22:33:44:55 10 | Pve-3,192.0.2.43,00:11:22:33:44:55 11 | Pve-4,192.0.2.44,00:11:22:33:44:55 12 | Pve-5,192.0.2.45,00:11:22:33:44:55 13 | Pve-6,192.0.2.46,00:11:22:33:44:55 14 | Pve-7,192.0.2.47,00:11:22:33:44:55 15 | Pve-8,192.0.2.48,00:11:22:33:44:55 16 | Pve-9,192.0.2.49,00:11:22:33:44:55" 17 | 18 | # Generic Functions ==========================================================# 19 | 20 | helps(){ # Function to show help 21 | clear 22 | echo "Syntax: wolstart [-f ] [-i ] [-n] [-h|--help] -c -v" 23 | echo " - i the name of your NIC to use: eth0" 24 | echo " use if NIC AutoDetect don't work (more than 1 NIC)" 25 | echo " - f use a file for data /file: wolstart -f ~/my.wol.nodes" 26 | echo " use if you have no local data (nodeData)" 27 | echo " - n use ping by name instead of IP" 28 | echo " - h Show this help" 29 | echo " - c Copyright statement" 30 | echo " - v Version statement" 31 | echo " To use internal data: wolstarts [-n]" 32 | echo "" 33 | } 34 | 35 | version() { # Function to show version info 36 | echo "" 37 | echo "wolstart.sh Wake on Lan for Servers" 38 | echo "Part of the MyJourney project @ homelab.casaursus.net (based on a 20 year old script of mine)" 39 | echo "" 40 | echo "Created by Nalle Juslén 27.8.2020, version 1.1 1.12.2021" 41 | echo " v.2.0 4.1.2022, v. 2.1 9.3.2022, v. 2.2 29.8.2022" 42 | echo " v.3.0 1.9.2023, v. 3.1 6.9.2023" 43 | echo "" 44 | } 45 | 46 | copyright(){ # Function to show Copyright info 47 | echo "" 48 | echo "Copyright (C) 2023 Free Software Foundation, Inc." 49 | echo "License GPLv3+: GNU GPL version 3 or later " 50 | echo "" 51 | echo "This is free software; you are free to change and redistribute it." 52 | echo "There is NO WARRANTY, to the extent permitted by law." 53 | echo "" 54 | } 55 | 56 | useColors() { # Function to define colors ------------------------------------# 57 | # color code color as bold 58 | red=$'\e[31m'; redb=$'\e[1;31m' # call red with $red and bold as $redb 59 | grn=$'\e[32m'; grnb=$'\e[1;32m' # call as green $grn as bold green $grnb 60 | yel=$'\e[33m'; yelb=$'\e[1;33m' # call as yellow $yel as bold yellow $yelb 61 | blu=$'\e[34m'; blub=$'\e[1;34m' # call as blue $blu as bold blue $blub 62 | mag=$'\e[35m'; magb=$'\e[1;35m' # call as magenta $mag as bold magenta $magb 63 | cyn=$'\e[36m'; cynb=$'\e[1;36m' # call as cyan $cyn as cyan bold $cynb 64 | end=$'\e[0m' 65 | } 66 | 67 | spinner() { # Function to display an animated spinner Choose a array -------------------# 68 | local array1=("◐" "◓" "◑" "◒") 69 | local array2=("░" "▒" "▓" "█") 70 | local array3=("╔" "╗" "╝" "╚") 71 | local array4=("┌" "┐" "┘" "└") 72 | local array5=("▄" "█" "▀" "█") 73 | local array6=("⠋" "⠙" "⠹" "⠸" "⠼" "⠴" "⠦" "⠧" "⠇" "⠏") 74 | local array7=("܀" " " "܀") 75 | local array8=(" " "٠" " " "٠" " " "܀" "܀") 76 | local array9=("🌑" "🌒" "🌓" "🌔" "🌕" "🌖" "🌘") #running moon 77 | 78 | local delays=0.3 # Delay between each character 79 | tput civis # Hide cursor 80 | while :; do 81 | for character in "${array7[@]}"; do # Which Array to Use 82 | printf "%s" "$character" 83 | sleep "$delays" 84 | printf "\b" # Move the cursor back 85 | done 86 | done 87 | } 88 | 89 | setroot() { # Function I am root ---------------------------------------------# 90 | if [[ "$EUID" -ne 0 ]]; then # 0 = I am root 91 | sudo -k 92 | if sudo true ; then # Correct password 93 | return 94 | else 95 | echo "${redb} Wrong password! Execution halted" 96 | exit #exit if 3 times wrong 97 | fi 98 | fi 99 | } 100 | 101 | # Local Functions ============================================================# 102 | 103 | initDataLocal() { # Function read local data and split the csv_data into the arrays 104 | i=1 105 | while IFS=',' read -r nameArray ipArray macArray; do 106 | nameArray+=("$nameArray"); ipArray+=("$ipArray"); macArray+=("$macArray") 107 | (( nodes++ )) 108 | done <<< "$nodeData" # Read local data 109 | } 110 | 111 | initDataFile() { # Function read and split the file with csv_data into the arrays 112 | i=1 113 | while IFS=',' read -r nameArray ipArray macArray; do 114 | nameArray+=("$nameArray"); ipArray+=("$ipArray"); macArray+=("$macArray") 115 | (( nodes++ )) 116 | done < "${wolFile}" # Read from file /dir/file 117 | } 118 | 119 | testPing () { # Function to test by ping if a Server is down -----------------# 120 | RETRY=1 121 | ping -I $myNIC -c $RETRY $1 > /dev/null 2>&1 # ping with no output 122 | status=$? 123 | return $status 124 | } 125 | 126 | downServers() { # Fuction checking for down servers --------------------------# 127 | i=1 128 | while [ $i -le $nodes ] 129 | do 130 | statusArray[$i]='' 131 | if [ $byn == true ]; then testPing ${nameArray[$i]}; else testPing ${ipArray[$i]}; fi 132 | statusArray[$i]=$? 133 | if [[ ${statusArray[$i]} == 0 ]]; then # display status 134 | echo -e "\b ${nameArray[$i]}\t ${grn}✔ running ${end}" 135 | else 136 | echo -e "\b ${nameArray[$i]}\t ${red}✘ off line ${end}" 137 | fi 138 | (( i++ )) 139 | done 140 | } 141 | 142 | askStart() { # Function Ask to start down Servers ----------------------------# 143 | tput setaf 3 144 | echo -e "\n$yel \e[4mStart Servers not running \e[0m" 145 | i=1 146 | while [ $i -le $nodes ] 147 | do 148 | if [[ ${statusArray[$i]} -ne 0 ]]; then 149 | read -rp " Start node: ${nameArray[$i]} ${ipArray[$i]} [y/N] : " o 150 | startArray[$i]=$o 151 | fi 152 | (( i++ )) 153 | done 154 | } 155 | 156 | startServers() { # Function for starting servers chosen to run ---------------# 157 | i=1; err=0 158 | while [ $i -le $nodes ] 159 | do 160 | if [[ ${startArray[$i]} == [yY] ]]; then 161 | echo -e "$yel \b Booting up: $end\b ${nameArray[$i]} @ ${ipArray[$i]} MAC ${macArray[$i]}"; 162 | sudo etherwake -i $myNIC ${macArray[$i]} 2>/dev/null 163 | if [ $? == 0 ]; then tput cuu1; echo -e "$grn✔$end"; else tput cuu1; err=1; echo -e "$red✘$end"; fi 164 | sleep .5; 165 | fi 166 | (( i++ )) 167 | done 168 | echo -e "\n$grnb\bSelected Servers start to boot up, it will take several minutes.$end" 169 | if [ $err == 1 ]; then echo -e "$redb \bError$end$yel Servers with the $red✘$yel prefix faild the start command.$end"; fi 170 | exit 171 | } 172 | 173 | # Code Section ===============================================================# 174 | 175 | while getopts ":i:hf:ncv" option; do # Get Options ---------------------------# 176 | case $option in 177 | i) nic=true; myNIC=$OPTARG;; 178 | f) byf=true; wolFile=$OPTARG;; 179 | n) byn=true; pingn="by name";; 180 | c) copyright; exit;; 181 | v) version; exit;; 182 | h) helps; exit;; 183 | \?) echo "Error: Invalid option"; exit;; 184 | esac 185 | done # -----------------------------------------------------------------------# 186 | 187 | useColors # Use color codes 188 | clear # Clear the screan 189 | if [ $nic == false ]; then myNIC=$( ls /sys/class/net | grep ^e); fi #NIC AutoDetect 190 | 191 | # Main Script ================================================================# 192 | 193 | if [ $byf == false ]; then # Using local 194 | echo -e "\n$yelb \bStart locally stored nodes$end" 195 | initDataLocal 196 | else # use a file 197 | echo -e "\n$yelb \bStart nodes in file:$end $wolFile $yel \busing$end $myNIC$yel" 198 | initDataFile 199 | fi 200 | 201 | tput setaf 3 # Set text to yellow foreground 202 | echo -e "\nInitialaizing with ping $end$pingn$yel" 203 | echo -e "\b Servers now running out of the$end $nodes$yel nodes$end" 204 | #tput sgr0 # set graphic rendition to default 205 | echo -e " \e[4mnode status \e[0m" 206 | 207 | # Run function and/or coude with a spinner. Start spinner and save the PID ---# 208 | spinner & 209 | spinner_pid=$! 210 | # Run your commands with spinner running 211 | downServers 212 | # Terminate the Spinner Show the Cursor Again 213 | kill "$spinner_pid"; wait "$spinner_pid" 2>/dev/null; tput cnorm 214 | #-----------------------------------------------------------------------------# 215 | 216 | # Do you want to run the rest of the script 217 | read -rp $'\n\e[1;36m Do you like to continue [Yn]: \e[0m' continue 218 | if [[ $continue == [nN] ]]; then 219 | exit 220 | else 221 | askStart # Function asking to start nodes not running 222 | read -rp $'\n\e[1;36m Start selected Servers [y/N] : \e[0m' ok # Ask for confirmation 223 | echo "" 224 | if [[ $ok == [yY] ]]; then 225 | setroot; tput cuu1; startServers # Function Start the choosen ones 226 | else 227 | echo -e "\n${redb} No Servers Started. $end${yel}Operators choise ${end}" 228 | fi 229 | fi 230 | # End of script ==============================================================# 231 | -------------------------------------------------------------------------------- /scripts/wolstart.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # wolstart.sh Wake on Lan for Proxmox Nodes 4 | # Part of the MyJourney project @ homelab.casaursus.net (based on a 20 year old script of mine) 5 | # 6 | # Created by Nalle Juslén 27.8.2020, version 1.1 1.12.2021 7 | # v.2.0 4.1.2022, v. 2.1 9.3.2022, v. 2.2 29.8.2022 8 | # v.3.0 1.9.2023, v. 3.1 6.9.2023 9 | # 10 | # 11 | # Copyright (C) 2023 Free Software Foundation, Inc. 12 | # License GPLv3+: GNU GPL version 3 or later 13 | # 14 | # This is free software; you are free to change and redistribute it. 15 | # There is NO WARRANTY, to the extent permitted by law. 16 | # 17 | 18 | # Data Section Arrays and variables ==========================================# 19 | macArray=(); ipArray=(); nameArray=(); statusArray=();startArray=() 20 | err=0; wolFile=""; nodes=0 # Tally on nodes 21 | 22 | nodeData="NAS-1,192.0.2.40,00:11:22:33:44:55 23 | Pve-1,192.0.2.41,00:11:22:33:44:55 24 | Pve-2,192.0.2.42,00:11:22:33:44:55 25 | Pve-3,192.0.2.43,00:11:22:33:44:55 26 | Pve-4,192.0.2.44,00:11:22:33:44:55 27 | Pve-5,192.0.2.45,00:11:22:33:44:55 28 | Pve-6,192.0.2.46,00:11:22:33:44:55 29 | Pve-7,192.0.2.47,00:11:22:33:44:55 30 | Pve-8,192.0.2.48,00:11:22:33:44:55 31 | Pve-9,192.0.2.49,00:11:22:33:44:55" 32 | 33 | # Generic Functions ==========================================================# 34 | 35 | useColors() { # Function to define colors ------------------------------------# 36 | # color code color as bold 37 | red=$'\e[31m'; redb=$'\e[1;31m' # call red with $red and bold as $redb 38 | grn=$'\e[32m'; grnb=$'\e[1;32m' # call as green $grn as bold green $grnb 39 | yel=$'\e[33m'; yelb=$'\e[1;33m' # call as yellow $yel as bold yellow $yelb 40 | blu=$'\e[34m'; blub=$'\e[1;34m' # call as blue $blu as bold blue $blub 41 | mag=$'\e[35m'; magb=$'\e[1;35m' # call as magenta $mag as bold magenta $magb 42 | cyn=$'\e[36m'; cynb=$'\e[1;36m' # call as cyan $cyn as cyan bold $cynb 43 | end=$'\e[0m' 44 | } 45 | 46 | spinner() { # Function to display an animated spinner Choose a array -------------------# 47 | local array1=("◐" "◓" "◑" "◒") 48 | local array2=("░" "▒" "▓" "█") 49 | local array3=("╔" "╗" "╝" "╚") 50 | local array4=("┌" "┐" "┘" "└") 51 | local array5=("▄" "█" "▀" "█") 52 | local array6=("⠋" "⠙" "⠹" "⠸" "⠼" "⠴" "⠦" "⠧" "⠇" "⠏") 53 | local array7=("܀" " " "܀") 54 | local array8=(" " "٠" " " "٠" " " "܀" "܀") 55 | local array9=("🌑" "🌒" "🌓" "🌔" "🌕" "🌖" "🌘") #running moon 56 | 57 | local delays=0.3 # Delay between each character 58 | tput civis # Hide cursor 59 | while :; do 60 | for character in "${array7[@]}"; do # Which Array to Use 61 | printf "%s" "$character" 62 | sleep "$delays" 63 | printf "\b" # Move the cursor back 64 | done 65 | done 66 | } 67 | 68 | setroot() { # Function I am root ---------------------------------------------# 69 | if [[ "$EUID" -ne 0 ]]; then # 0 = I am root 70 | sudo -k 71 | if sudo true ; then # Correct password 72 | return 73 | else 74 | echo "${redb} Wrong password! Execution halted" 75 | exit #exit if 3 times wrong 76 | fi 77 | fi 78 | } 79 | 80 | # Local Functions ============================================================# 81 | 82 | initDataLocal() { # Function read local data and split the csv_data into the arrays 83 | i=1 84 | while IFS=',' read -r nameArray ipArray macArray; do 85 | nameArray+=("$nameArray"); ipArray+=("$ipArray"); macArray+=("$macArray") 86 | (( nodes++ )) 87 | done <<< "$nodeData" # Read local data 88 | } 89 | 90 | testPing () { # Function to test by ping if a Server is down -----------------# 91 | RETRY=1 92 | ping -c $RETRY $1 > /dev/null 2>&1 # ping with no output 93 | status=$? 94 | return $status 95 | } 96 | 97 | downServers() { # Fuction checking for down servers --------------------------# 98 | i=1 99 | while [ $i -le $nodes ] 100 | do 101 | statusArray[$i]='' 102 | testPing ${ipArray[$i]} 103 | statusArray[$i]=$? 104 | if [[ ${statusArray[$i]} == 0 ]]; then # display status 105 | echo -e "\b ${nameArray[$i]}\t ${grn}✔ running ${end}" 106 | else 107 | echo -e "\b ${nameArray[$i]}\t ${red}✘ off line ${end}" 108 | fi 109 | (( i++ )) 110 | done 111 | } 112 | 113 | askStart() { # Function Ask to start down Servers ----------------------------# 114 | tput setaf 3 115 | echo -e "\n$yel \e[4mStart Servers not running \e[0m" 116 | i=1 117 | while [ $i -le $nodes ] 118 | do 119 | if [[ ${statusArray[$i]} -ne 0 ]]; then 120 | read -rp " Start node: ${nameArray[$i]} ${ipArray[$i]} [y/N] : " o 121 | startArray[$i]=$o 122 | fi 123 | (( i++ )) 124 | done 125 | } 126 | 127 | startServers() { # Function for starting servers chosen to run ---------------# 128 | i=1; err=0 129 | while [ $i -le $nodes ] 130 | do 131 | if [[ ${startArray[$i]} == [yY] ]]; then 132 | echo -e "$yel \b Booting up: $end\b ${nameArray[$i]} @ ${ipArray[$i]} MAC ${macArray[$i]}"; 133 | sudo etherwake -i $myNIC ${macArray[$i]} 2>/dev/null 134 | if [ $? == 0 ]; then tput cuu1; echo -e "$grn✔$end"; else tput cuu1; err=1; echo -e "$red✘$end"; fi 135 | sleep .5; 136 | fi 137 | (( i++ )) 138 | done 139 | echo -e "\n$grnb\bSelected Servers start to boot up, it will take several minutes.$end" 140 | if [ $err == 1 ]; then echo -e "$redb \bError$end$yel Servers with the $red✘$yel prefix faild the start command.$end"; fi 141 | exit 142 | } 143 | 144 | # Code Section ===============================================================# 145 | 146 | useColors # Use color codes 147 | clear # Clear the screan 148 | myNIC=$( ls /sys/class/net | grep ^e) #NIC AutoDetect 149 | 150 | # Main Script ================================================================# 151 | 152 | echo -e "\n$yelb \bStart Proxmox nodes$end" 153 | initDataLocal 154 | 155 | tput setaf 3 # Set text to yellow foreground 156 | echo -e "\nInitialaizing with ping" 157 | echo -e "\b Servers now running" 158 | tput sgr0 # set graphic rendition to default 159 | echo -e " \e[4mnode status \e[0m" 160 | 161 | # Run function and/or coude with a spinner. Start spinner and save the PID ---# 162 | spinner & 163 | spinner_pid=$! 164 | # Run your commands with spinner running 165 | downServers 166 | # Terminate the Spinner Show the Cursor Again 167 | kill "$spinner_pid"; wait "$spinner_pid" 2>/dev/null; tput cnorm 168 | #-----------------------------------------------------------------------------# 169 | 170 | # Do you want to run the rest of the script 171 | read -rp $'\n\e[1;36m Do you like to continue [Yn]: \e[0m' continue 172 | if [[ $continue == [nN] ]]; then 173 | exit 174 | else 175 | askStart # Function asking to start nodes not running 176 | read -rp $'\n\e[1;36m Start selected Servers [y/N] : \e[0m' ok # Ask for confirmation 177 | echo "" 178 | if [[ $ok == [yY] ]]; then 179 | setroot; tput cuu1; startServers # Function Start the choosen ones 180 | else 181 | echo -e "\n${redb} No Servers Started. $end${yel}Operators choise ${end}" 182 | fi 183 | fi 184 | # End of script ==============================================================# 185 | -------------------------------------------------------------------------------- /showIPconfig.sh: -------------------------------------------------------------------------------- 1 | @echo off 2 | echo\ 3 | echo I am logged on as: %UserName%. 4 | echo My computer's name is %ComputerName%. 5 | echo My IP settings: 6 | ipconfig | find "." | find /i /v "suffix" 7 | echo\ 8 | echo Press [Space bar] to close 9 | pause > nul 10 | -------------------------------------------------------------------------------- /sshr: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # SSH into a VM 3 | # Activate by mv sshr .bin/ (or cp sshr .bin/) 4 | # Useage: sshr 55 -> ssh pomo@182.168.1.55 5 | ssh root@192.168.1.$1 -------------------------------------------------------------------------------- /templatebuilder.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ## templatebuilder.sh ver. 1.2 for Ubuntu 22.04 Servers 3 | ## A basic set of commands, for more see: https://pve.proxmox.com/pve-docs/qm.conf.5.html 4 | 5 | #=============================================================================# 6 | # Get the cloud image of choise, Ubuntu as example, it's a .qcow2 fil with the extension img - we turn it back to .qcow2 7 | wget -O base.qcow2 https://cloud-images.ubuntu.com/minimal/releases/jammy/release/ubuntu-22.04-minimal-cloudimg-amd64.img 8 | #wget -O base.qcow2 https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img 9 | #-----------------------------------------------------------------------------# 10 | # Resize the disk to your needs, 8 - 32G is normal 11 | qemu-img resize base.qcow2 16G 12 | # Add QEMU Guest Agent and any other packages you’d like in your base image. 13 | # libguestfs-tools has to be installed on the node 14 | #apt-get update && apt-get install libguestfs-tools 15 | # Add the QEMU-Guest-Agent to auto install 16 | # virt-customize --install qemu-guest-agent -a base.qcow2 17 | #=============================================================================# 18 | # # 19 | # Create the template ========================================================# 20 | # 21 | # Choose RAM, Disk size, # of cores, what bridge to use. virtio is mandatory 22 | qm create 9000 --memory 1024 --core 1 --name ubuntu-mini --net0 virtio,bridge=vmbr0 23 | # Import the disc to the base of the template. Where to put the VM local-lvm 24 | qm importdisk 9000 base.qcow2 local-lvm 25 | #-----------------------------------------------------------------------------# 26 | # Attache the disk to the base of the template 27 | qm set 9000 --scsihw virtio-scsi-pci --scsi0 locl-lvm:vm-9000-disk-0 28 | #-----------------------------------------------------------------------------# 29 | # Attach the cloudinit file - you NEED to EDIT it later ! 30 | qm set 9000 --ide2 local-lvm:cloudinit 31 | # Make the cloud init drive bootable and only boot from this disk 32 | qm set 9000 --boot c --bootdisk scsi0 33 | #-----------------------------------------------------------------------------# 34 | # Add serial console, to be able to see console output! 35 | qm set 9000 --serial0 socket --vga serial0 36 | #-----------------------------------------------------------------------------# 37 | # Autostart vm at boot - default is 0 38 | #qm set 9000 --onboot 1 39 | #-----------------------------------------------------------------------------# 40 | # Use Qemu Guest Agent - default is 0 41 | qm set 9000 --agent 1 42 | #-----------------------------------------------------------------------------# 43 | # Set OS type Linux 5.x kernel 2.6 - default is other 44 | qm set 9000 --ostype l26 45 | #-----------------------------------------------------------------------------# 46 | # Set dhcp on 47 | qm set 9000 --ipconfig0 ip="dhcp" 48 | #-----------------------------------------------------------------------------# 49 | # # 50 | ## More automation can be added to cloud-init, examplesbelow -----------------# 51 | # 1. copy your key to the node or to the VM 52 | #ssh-copy-id -i ~/.ssh/id_ed25519 our_username@other_machine 53 | # 2. set up credentials 54 | #qm set 9000 --ciuser "admin" # use your imagination 55 | #qm set 9000 --cipassword "Pa$$w0rd" # use a super complicated one 56 | #qm set 9000 --sshkey ~/.ssh/my_key # sets the users key to the vm 57 | # 3. use a bootstrap file at the initial boot that can have snippets. 58 | # You need to check the status of the Storage Manager and set according to yours 59 | #pvesm status 60 | #pvesm set local --content backup,iso,snippets,vztmpl 61 | #qm set 9000 --cicustom "vendor=:snippets/vendor.yaml" 62 | #-----------------------------------------------------------------------------# 63 | # Create the template 9000 64 | #qm template 9000 65 | #sleep 15 66 | # Cloning the template 67 | #qm clone 9000 5001 --name Pod1 --full 68 | #qm clone 9000 5002 --name Pod2 --full 69 | #qm clone 9000 5003 --name Pod3 --full 70 | #-----------------------------------------------------------------------------# 71 | # # 72 | # End of code ================================================================# 73 | 74 | echo "" 75 | echo "Remenmer do NOT start the VM before making it into a template !" 76 | echo "" 77 | echo "WARNING - Do NOT start the VM - WARNING" 78 | sleep 2 79 | echo "" 80 | echo "Edit the Cloud-Init NOW ... then clone your VM's" 81 | sleep 5 -------------------------------------------------------------------------------- /unboundpi.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: '3' 3 | 4 | services: 5 | pihole: 6 | container_name: pihole 7 | hostname: pihole 8 | image: pihole/pihole:latest 9 | networks: 10 | kadulla: 11 | ipv4_address: 172.18.0.250 12 | ports: 13 | - "53:53/tcp" 14 | - "53:53/udp" 15 | - "80:80/tcp" 16 | - "443:443/tcp" 17 | environment: 18 | - 'TZ=Europe/Helsinki' 19 | - 'WEBPASSWORD=SecretPa$$word' 20 | - 'DNS1=172.18.0.251#5053' 21 | - 'DNS2=no' 22 | volumes: 23 | - './etc-pihole/:/etc/pihole/' 24 | - './etc-dnsmasq.d/:/etc/dnsmasq.d/' 25 | restart: unless-stopped 26 | depends_on: 27 | - unbound 28 | # DNS server 29 | unbound: 30 | container_name: piunbound 31 | image: mvance/unbound:latest 32 | networks: 33 | kadulla: 34 | ipv4_address: 172.18.0.251 35 | volumes: 36 | - ./unbound:/opt/unbound/etc/unbound 37 | - ./unbound/a-records.conf:/opt/unbound/etc/unbound/a-records.conf:ro 38 | ports: 39 | - "5053:5053/tcp" 40 | - "5053:5053/udp" 41 | healthcheck: 42 | disable: true 43 | restart: unless-stopped 44 | # VPN server for road warriors 45 | pivpn: 46 | container_name: pivpn 47 | #image: pivpn/pivpn.io 48 | image: archef2000/pivpn 49 | hostname: pivpn 50 | volumes: 51 | - ./ovpns:/home/pivpn/ovpns 52 | - ./openvpn:/etc/openvpn 53 | - ./pivpn:/etc/pivpn/openvpn 54 | environment: 55 | - HOST=myserver.lan 56 | - PROTO=udp # or tcp 57 | - VPN=openvpn 58 | - PORT=1194 # change this for security 59 | # optionals - you edit for your environment 60 | - CLIENT_NAME=pivpn 61 | - NET=10.9.8.0 62 | - TWO_POINT_FOUR=1 # or 0 63 | - DNS1=1.1.1.1 # Client DNS 64 | - DNS2=9.9.9.9 # Client DNS 65 | - INTERFACE=eth0 # your Interface 66 | - ENCRYPT=521 # 256, 384, or 521 67 | # if TWO_POINT_FOUR=0 then ENCRYPT needs to be 2048, 3072, or 4096 68 | privileged: true # True to run Openvpn 69 | restart: unless-stopped 70 | networks: 71 | kadulla: 72 | ipv4_address: 172.18.0.252 73 | 74 | # Networks to be used 75 | networks: 76 | kadulla: 77 | external: 78 | 'true' 79 | ... 80 | -------------------------------------------------------------------------------- /watchtower/docker-compose.yml: -------------------------------------------------------------------------------- 1 | --- 2 | version: '3' 3 | # auto update containers 4 | # May cause interupts and other issues 5 | services: 6 | watchtower: 7 | image: containrrr/watchtower 8 | container_name: watchtower 9 | restart: unless-stopped #always 10 | environment: 11 | - TZ=Europe/Helsinki 12 | - WATCHTOWER_SCHEDULE=0 0 4 * * * 13 | - WATCHTOWER_CLEANUP=true 14 | - WATCHTOWER_INCLUDE_STOPPED=true 15 | # - WATCHTOWER_POLL_INTERVAL=3600 # in sec. 24h = 86400 16 | volumes: 17 | - /var/run/docker.sock:/var/run/docker.sock 18 | networks: 19 | - pihalla 20 | # networks to be used by service 21 | networks: 22 | pihalla: 23 | external: true 24 | --------------------------------------------------------------------------------