Last active
October 25, 2022 16:55
-
-
Save Abreto/8bc394e7bcf55f344bb92230c4e81141 to your computer and use it in GitHub Desktop.
Server related scripts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
[ $(id -u) -eq 0 ] || sh_c=sudo | |
do_it() { | |
#if [ ! $(id -u) -eq 0 ]; then | |
# echo Sorry but I require root privileges. | |
# exit -1 | |
#fi | |
set -x | |
$sh_c apt update | |
which curl || $sh_c apt install -y curl | |
curl -fsSL https://get.docker.com | $sh_c sh | |
$sh_c apt-get install docker-compose-plugin | |
[ ! $(id -u) -eq 0 ] && $sh_c usermod -aG docker $USER | |
$sh_c sh -c 'echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf' | |
$sh_c sh -c 'echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf' | |
$sh_c sh -c 'echo "net.ipv4.tcp_fastopen = 3" >> /etc/sysctl.conf' | |
$sh_c sh -c 'echo "fs.file-max = 2097152" >> /etc/sysctl.conf' | |
# $sh_c echo 'echo 3 > /proc/sys/net/ipv4/tcp_fastopen' >> /etc/rc.local | |
$sh_c sysctl -p | |
} | |
do_it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
set -xe | |
sudo adduser --disabled-password --gecos "" ci | |
sudo usermod -aG docker ci | |
sudo -H -u ci sh -s << 'EOF' | |
set -xe | |
mkdir -p ~/.ssh | |
cd ~/.ssh | |
ssh-keygen -t ed25519 -f id_ed25519 -q -N "" | |
cat id_ed25519.pub | tee -a authorized_keys | |
cat id_ed25519 | |
EOF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
# Usage: sudo ./ubuntu-enable-bbr.sh | |
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf | |
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf | |
sysctl -p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# !!! This script requires root privileges !!! | |
# | |
# Usage: | |
# # ./ubuntu-get-docker-ce.sh | |
# or | |
# $ sudo ./ubuntu-get-docker-ce.sh | |
if [ ! $(id -u) -eq 0 ]; then | |
echo Sorry but this script requires root privileges. | |
exit -1 | |
fi | |
apt-get update | |
apt-get install -y \ | |
apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
gnupg-agent \ | |
software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - | |
apt-key fingerprint 0EBFCD88 | |
add-apt-repository \ | |
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) \ | |
stable" | |
apt-get update | |
apt-get install -y docker-ce docker-ce-cli containerd.io | |
curl -L "https://github.com/docker/compose/releases/download/1.24.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
chmod +x /usr/local/bin/docker-compose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
牛皮