検証用 Ubuntu 24.04 初期セットアップスクリプト
以前に「検証用 Ubuntu 22.04LTS 初期セットアップスクリプト」を用意し、Linux でよく使うコマンドのチートシート に実行方法をメモしておきました。 内容は殆ど変わりませんが、検証用 Ubuntu 24.04 の初期セットアップスクリプトを作成したので改めてメモしておきます。 以下のコマンドラインで実行出来ます。
| curl -sL https://raw.githubusercontent.com/sig9org/init-linux/master/init-ubuntu24.sh | bash -s
|
スクリプトの内容
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 | #!/bin/bash
dt_start=$( date +"%s" )
# Set the timezone
timedatectl set-timezone Asia/Tokyo
# Configure NTP servers
cat << EOF >> /etc/systemd/timesyncd.conf
NTP=162.159.200.123 162.159.200.1
EOF
# Update sshd
sed -i -e "s/#ClientAliveInterval 0/ClientAliveInterval 60/g" /etc/ssh/sshd_config
sed -i -e "s/#ClientAliveCountMax 3/ClientAliveCountMax 5/g" /etc/ssh/sshd_config
# Disable SSH client warnings
cat << EOF > /etc/ssh/ssh_config.d/99_lab.conf
KexAlgorithms +diffie-hellman-group1-sha1
Ciphers aes128-cbc,aes256-ctr
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
EOF
# Disable AppArmor
systemctl stop apparmor.service
systemctl disable apparmor.service
# Customize the prompt display
cat << 'EOF' >> ~/.bashrc
# Modify the prompt.
if [ `id -u` = 0 ]; then
PS1="\[\e[1;31m\]\u@\h \W\\$ \[\e[m\]"
else
PS1="\[\e[1;36m\]\u@\h \W\\$ \[\e[m\]"
fi
EOF
# Disable welcome message
cat << EOF > ~/.hushlogin
exit
EOF
# Control needrestart
cat << 'EOF' > /etc/needrestart/conf.d/99_restart.conf
$nrconf{kernelhints} = '0';
$nrconf{restart} = 'a';
EOF
# Install basic packages
apt -y update
apt -y install \
curl \
fping \
git \
nmap \
tree \
unzip \
zip
# Update system
apt -y upgrade
# Install uncmnt
curl -L https://github.com/sig9org/uncmnt/releases/download/v0.0.2/uncmnt_v0.0.2_linux_amd64 -o /usr/local/bin/uncmnt && \
chmod 755 /usr/local/bin/uncmnt
# Install asdf
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.13.1
cat << 'EOF' >> ~/.bashrc
# asdf settings
. "$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"
EOF
. "$HOME/.asdf/asdf.sh"
. "$HOME/.asdf/completions/asdf.bash"
# Install direnv
asdf plugin add direnv
asdf install direnv 2.33.0
asdf global direnv 2.33.0
cat << 'EOF' >> ~/.bashrc
# direnv settings
export EDITOR=vim
eval "$(direnv hook bash)"
EOF
# Install Python
apt -y install \
build-essential \
curl \
libbz2-dev \
libffi-dev \
liblzma-dev \
libncursesw5-dev \
libreadline-dev \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
libxmlsec1-dev \
tk-dev \
xz-utils \
zlib1g-dev
asdf plugin add python
asdf install python 3.12.1
asdf global python 3.12.1
# Reboot
dt_end=$( date +"%s" )
elapsed=$((dt_end - dt_start))
echo "##############################"
echo "Elapsed time: ${elapsed} seconds."
echo "##############################"
reboot
|