-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1-install.sh
140 lines (136 loc) · 6.2 KB
/
1-install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
# Obsolete see the newmyVMsetup.sh
#--------------------------------------------------------#
# 1-install.sh 2.0 Part 1 of the Journey #
# MyJourney project homelab.casaursus.net #
# #
# V.1 Created by Nalle Juslen 10.01.2022 as 2 scripts #
# -review 9.2.2022 #
# #
# V.2 created 10.02.2022 Prepare VM for Docker-Stack #
# - revison #
#--------------------------------------------------------#
# Declare function hyrraPyorii Show a activity spinner --#
hyrraPyorii (){ #
pid=$! # Process Id of the previous running command #
x='-\|/' # hyrra in its elements #
i=0 #
while kill -0 $pid 2>/dev/null #
do #
i=$(( (i+1) %4 )) #
printf "\r ${x:$i:1}" #
sleep .1 #
done #
printf "\r " #
} #
hyrraPyorii #
# -------------------------------------------------------#
clear
echo ""
echo "Starting upgrade/install of apps for the Docker-stack"
echo ""
echo " WARNING - DON'T run scripts without editing - WARNING"
echo ""
echo " Warning . This script will pull parts from my GitHub"
echo ""
lsb_release -a #print lsb-release info
echo ""
echo "Preparing the VM"
# Add bash_aliases ------------------------------------------------------------
wget https://raw.githubusercontent.com/nallej/MyJourney/main/.bash_aliases &> /dev/null
. ~/.bash_aliases
echo " - added .bash_aliases"
# running install -------------------------------------------------------------
echo ""
echo " - starting Install"
echo " WARNING Rread the code - edit and the run!"
read -rp " - Do you want to do the Install [y/n] " DPI
if [[ "$DPI" = [yY] ]]; then
echo " - Running VM updates and installs ..."
# This is the main part update-install-upgrade ------------------------------
echo "**** Initial install/upgrade stage **** **** ****" > ~/install.log
sudo ls &> /dev/null # dummy to get sudo psw
(sudo apt-get update &&
sudo apt-get install curl apt-transport-https ca-certificates software-properties-common fail2ban -y &&
sudo apt-get upgrade -y
) >> ~/install.log 2>&1 &
hyrraPyorii
echo " - starting Docker Pre-Install ..."
echo "**** Docker Pre Install stage **** **** ****" >> ~/install.log
wget https://github.com/nallej/MyJourney/raw/main/LICENSE &> /dev/null
# set your timezone ---------------------------------------------------------
echo " - TZ = Helsinki" # change to your timezone
sudo timedatectl set-timezone Europe/Helsinki
# ---------------------------------------------------------------------------
read -rp " - Are you ruinning 1-Focal 2-Hirsute 0=Quit : " OS # <<< add deb
echo " - LTS is recomended use Focal Stable"
if [[ "$OS" != [1] ]]; then
echo "You need to edit the script"
exit
else
echo " ... upgrading sw ..."
echo "**** second install/upgrade stage **** **** ****" >> ~/install.log
( # Add keys -----------------------------------------------------------
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - &&
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" &&
# LTS is recomendded focal stable (hirsute, impish) ------------------
sudo apt-cache policy docker-ce &&
sudo apt-get update &&
sudo apt-get upgrade -y
) >> ~/install.log 2>&1 &
hyrraPyorii
fi
echo ""
echo " - Setting up unattenden updates = yes "
echo "**** Docker Pre Install stage **** **** ****" >> ~/install.log
(sudo systemctl enable unattended-upgrades --now) >> ~/install.log 2>&1 &
echo ""
echo " WARNING - Do you want to clear old updates?"
read -rp " - Clear old updates [y/n] " COU
if [[ "$COU" = [yY] ]]; then
echo " - Deliting old installs ..."
(sudo apt-get clean &&
sudo apt-get autoremove) >> ~/install.log 2>&1 &
fi
# This is only needed for Proxmox VM's ------------------------#
echo "" #
read -rp " - Install QGA for Proxmox VM [y/n] " QGA #
if [[ "$QGA" = [yY] ]]; then #
sudo apt-get install -q -y qemu-guest-agent &> /dev/null #
fi #
# qemu-quest-agent --------------------------------------------#
# Giv your stack a name or use default: docker-stack --------------------------
mkdir docker-stack
cd docker-stack
wget https://raw.githubusercontent.com/nallej/MyJourney/main/2-install.sh &> /dev/null
chmod +x 2-install.sh
# =============================================================================
echo ""
echo ""
echo ""
echo "All done ! "
echo " - Licens copied to current folder "
echo " - Next script is in ~/docker-stack/ - 2-install.sh "
echo " - install.log written, check for errors "
echo ""
echo ""
echo "Ready for the next script ? "
echo " - Read the code, change to your needs, add your stuff and passwords ! "
echo " - reboot is mandatory"
echo ""
echo "You should now: "
echo " - Power off and change VM settings "
echo " - Edit the script: ~/docker-stack/2-install.sh "
echo ""
sleep 2s
read -rp "Do you want to reboot? [y/n] " RB
if [[ "$RB" = [yY] ]]; then
sudo reboot
fi
# end of install y/n
else
echo "Exit - automated process"
echo " - Edit the script: ~/docker-stack/2-install.sh "
echo " - Read the code, change to your needs, add your stuff and passwords ! "
echo " - REBOOT befor running ./2-install.sh"
fi