-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathbootstrap-sudo-linux-debian
executable file
·141 lines (124 loc) · 5.43 KB
/
bootstrap-sudo-linux-debian
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
#!/usr/bin/env bash
set -euo pipefail
YP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." >/dev/null && pwd)"
source ${YP_DIR}/sh/common.inc.sh
source ${YP_DIR}/sh/package-managers/apt.inc.sh
if [[ "${EUID}" != "0" ]]; then
echo_info "EUID=${EUID}"
[[ -n "${YP_SUDO}" ]] || {
echo_info "YP_SUDO=${YP_SUDO}"
echo_err "Restarting this shell script as root is impossible."
exit 1
}
echo_warn "Restarting this shell script as root."
exe ${YP_SUDO} --preserve-env --set-home ${BASH_SOURCE[0]}
exit 0
fi
export DEBIAN_FRONTEND=noninteractive
export DEBCONF_NONINTERACTIVE_SEEN=true
# keep in sync with dockerfiles/yp-debian/Dockerfile.build.sh
echo_do "Setup aptitude..."
apt_update
if [[ "${CI:-}" = "true" ]] && ${YP_DIR}/bin/is-wsl; then
# see https://github.com/microsoft/WSL/issues/8219#issuecomment-1110508016
apt_install_one gzip
gzip --version | head -1 || {
echo_do "Patch $(command -v gzip) for 'cannot execute binary file: Exec format error'..."
echo -en '\x10' | sudo dd of=$(command -v gzip) count=1 bs=1 conv=notrunc seek=$((0x189))
echo_done
}
# see https://github.com/microsoft/WSL/issues/8219#issuecomment-1133936081
# requirements for bin/wsl-fix-exec-format-error
apt_install_one python3
apt_install_one python3-pip
pip install pyelftools
fi
apt_install_one apt-transport-https
apt_install_one ca-certificates
apt_install_one software-properties-common
apt_install_one gnupg-agent
# ppa:git-core/ppa is only available on ubuntu
[[ "${OS_RELEASE_ID}" != "ubuntu" ]] || {
add-apt-repository ppa:git-core/ppa -y
apt_update
}
apt_install_one git
apt_install_one openssl
if [[ "${SEMAPHORE:-}" = "true" ]]; then
# cannot skip the prompt about /etc/ssh/sshd_config even though
# apt-get install sends dpkg option to choose to keep local version
# ┌──────────────────────┤ Configuring openssh-server ├──────────────────────┐
# │ /etc/ssh/sshd_config is available, but the version installed currently │
# │ has been locally modified. │
# │ │
# │ What do you want to do about modified configuration file sshd_config? │
# │ │
# │ install the package maintainer's version │
# │ keep the local version currently installed │
# │ show the differences between the versions │
# │ show a side-by-side difference between the versions │
# │ show a 3-way difference between available versions │
# │ do a 3-way merge between available versions │
# │ start a new shell to examine the situation │
# │ │
# │ │
# │ <Ok> │
# │ │
# └──────────────────────────────────────────────────────────────────────────┘
echo_skip "aptitude: Installing ssh-client..."
elif [[ "${TRAVIS:-}" = "true" ]]; then
# stalls after printing
# Setting up openssh-server (1:8.2p1-4ubuntu0.3) ...
# Installing new version of config file /etc/ssh/moduli ...
# rescue-ssh.target is a disabled or a static unit, not starting it.
echo_skip "aptitude: Installing ssh-client..."
else
apt_install_one ssh-client
fi
apt_install_one openssl
apt_install_one sudo
echo_done
echo_do "Setup debconf-utils..."
apt_install_one debconf-utils
echo '* libraries/restart-without-asking boolean true' | debconf-set-selections
echo_done
echo_do "Setup locales..."
apt_install_one locales
locale-gen en_US en_US.UTF-8
dpkg-reconfigure locales
echo_done
if [[ "${CI:-}" = "true" ]]; then
echo_do "Setup NTP to improve date-time sync..."
(
# see https://bugs.launchpad.net/ubuntu/+source/tzdata/+bug/1773687
ln -sfn /usr/share/zoneinfo/UTC /etc/localtime
apt_install_one tzdata
dpkg-reconfigure tzdata
if command -v timedatectl; then
timedatectl set-ntp no || true
fi
apt_install_one ntp
# test that ntpd is working
ntpq -p
) || true
echo_done
else
echo_skip "Setup NTP to improve date-time sync..."
fi
# Basic
echo_do "aptitude: Installing basic packages..."
# as per homebrew-install and https://docs.brew.sh/Homebrew-on-Linux#requirements
apt_install_one build-essential
apt_install_one curl
apt_install_one file
apt_install_one git
apt_install_one procps
apt_install_one bsdmainutils
apt_install_one uuid-runtime
apt_install_one zlib1g-dev
apt_install_one bash
apt_install_one python3-minimal
echo_done
# scripts tend to call /usr/bin/pyhon to intend calling python2 or python3, whichever is available
[[ -e /usr/bin/python ]] || ln -s /usr/bin/python3 /usr/bin/python
apt_list_installed