-
Notifications
You must be signed in to change notification settings - Fork 0
/
s_distro_fedora_ops
executable file
·218 lines (165 loc) · 4.66 KB
/
s_distro_fedora_ops
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
#!/usr/bin/env bash
#
# Bin is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Bin is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Bin. If not, see <https://www.gnu.org/licenses/>.
#
# Debug Options
set -euo pipefail
DEPS=(sudo dnf usermod command systemctl tee)
s_checkdeps "${DEPS[@]}"
INSTALL='sudo dnf install -y'
if [[ ! -x $(command -v podman) ]]; then
$INSTALL podman podman-compose
sudo systemctl enable podman.socket
sudo systemctl start podman.socket
sudo sysctl kernel.unprivileged_userns_clone
# Add a new group called podman so its easier to manage who can run podman w/out sudo
echo '%podman ALL=(ALL) NOPASSWD: /usr/bin/podman' | sudo tee -a /etc/sudoers.d/podman
# Set subuid and subgid
sudo touch /etc/subuid /etc/subgid
sudo chmod 644 /etc/subuid /etc/subgid
sudo usermod --add-subuids 100000-165535 --add-subgids 100000-165535 $USER
# Rootless Podman
podman system migrate
fi
exit
# TODO: check and up to date every statement below
if [[ ! -x $(command -v docker) ]]; then
# uninstall old versions
sudo dnf remove docker docker-client docker-client-latest \
docker-common docker-latest docker-latest-logrotate \
docker-logrotate docker-selinux docker-engine-selinux docker-engine
sudo dnf -y install dnf-plugins-core
sudo dnf config-manager \
--add-repo \
https://download.docker.com/linux/fedora/docker-ce.repo
sudo dnf install -y dnf-plugins-core docker-ce docker-ce-cli containerd.io
sudo systemctl start docker
sudo systemctl enable docker.service
sudo groupadd docker
sudo gpasswd -a $USER docker
sudo systemctl restart docker
# activate group, for now
newgrp docker
fi
_gcloud() {
_pre() {
sudo tee -a /etc/yum.repos.d/google-cloud-sdk.repo <<EOM
[google-cloud-sdk]
name=Google Cloud SDK
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el8-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOM
sudo dnf update -y
}
_install() {
sudo dnf install -y libxcrypt-compat.x86_64 google-cloud-sdk
}
for f in {_pre,_install}; do
$f
done
}
_aws() {
[[ -x $(command -v aws) ]] && return
_install() {
sudo dnf install -y awscli
}
_install
}
_terraform() {
[[ -x $(command -v terraform) ]] && return
_pre() {
sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
}
_install() {
sudo dnf install -y terraform
}
_pre
_install
}
_minikube() {
_pre() {
curl -o /tmp/minikube -L https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
}
_install() {
chmod +x /tmp/minikube
sudo mv /tmp/minikube /usr/local/bin/
}
_pre
_install
}
_kubectl() {
_pre() {
curl -o /tmp/kubectl -LO "https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl"
}
_install() {
chmod +x /tmp/kubectl
sudo mv /tmp/kubectl /usr/local/bin/
}
_pre
_install
}
_qemu() {
_install() {
sudo dnf install -y qemu
}
_install
}
_virtualbox() {
[[ -x $(command -v virtualbox) ]] && return
_install() {
sudo dnf install -y VirtualBox
}
_install
}
_ansible() {
[[ -x $(command -v ansible) ]] && return
_install() {
sudo dnf install -y ansible
}
_install
}
_virtualization() {
_install() {
sudo dnf install -y @virtualization
}
_services() {
sudo systemctl start libvirtd
sudo systemctl enable libvirtd
}
_post() {
sudo usermod -aG libvirt "$USER"
sudo usermod -aG kvm "$USER"
}
# run
for func in {_install,_services,_post}; do
$func
done
}
_vagrant() {
_install() {
sudo dnf install -y vagrant
}
_install
}
_podman_docker_compose() {
_post() {
# Docker Compose will use the correct socket.
export DOCKER_HOST=///run/user/$UID/podman/podman.sock
}
_post
}