Last active
September 7, 2021 13:00
-
-
Save Mikubill/e6bf3877a967e4689066a8fd03c62818 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/sh | |
# This script is meant for quick & easy install via: | |
# $ curl -fsSL https://gist.github.com/Mikubill/e6bf3877a967e4689066a8fd03c62818/raw/init.sh | bash | |
# | |
# For docker support: | |
# $ curl -fsSL https://gist.github.com/Mikubill/e6bf3877a967e4689066a8fd03c62818/raw/init.sh | bash -s docker | |
# | |
# For wireguard support: | |
# $ curl -fsSL https://gist.github.com/Mikubill/e6bf3877a967e4689066a8fd03c62818/raw/init.sh | bash -s wg | |
# | |
set -e | |
command_exists() { | |
command -v "$@" > /dev/null 2>&1 | |
} | |
user="$(id -un 2>/dev/null || true)" | |
# username="neko-$(tr -dc 0-9a-f </dev/urandom | head -c 2)" | |
# original="$(hostname)" | |
sh_c='sh -c' | |
if [ "$user" != 'root' ]; then | |
if command_exists sudo; then | |
sh_c='sudo -E sh -c' | |
elif command_exists su; then | |
sh_c='su -c' | |
else | |
cat >&2 <<-'EOF' | |
Error: this installer needs the ability to run commands as root. | |
We are unable to find either "sudo" or "su" available to make this happen. | |
EOF | |
exit 1 | |
fi | |
fi | |
set -x | |
# init | |
cd ~ | |
$sh_c 'apt-get update -qq >/dev/null' | |
$sh_c 'apt-get upgrade -y -qq >/dev/null' | |
$sh_c 'DEBIAN_FRONTEND=noninteractive apt-get install -y -qq curl zsh git vim htop vnstat nload busybox >/dev/null' | |
$sh_c 'apt-get autoremove -y >/dev/null' | |
mkdir -p .zsh .config .ssh | |
[ ! -d ~/.zsh/zsh-autosuggestions ] && git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zsh/zsh-autosuggestions >/dev/null | |
[ ! -d ~/.zsh/zsh-syntax-highlighting ] && git clone https://github.com/zsh-users/zsh-syntax-highlighting ~/.zsh/zsh-syntax-highlighting >/dev/null | |
echo "HISTFILE=~/.zsh_history\nHISTSIZE=10000\nSAVEHIST=10000\nsetopt SHARE_HISTORY\n" >> .zshrc | |
echo "source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh" >> .zshrc | |
echo "source ~/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" >> .zshrc | |
chmod 700 ~/.ssh | |
$sh_c 'echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf' | |
$sh_c 'echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf' | |
$sh_c "sed -i 's/^#PubkeyAuthentication\s\+yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config" | |
$sh_c "sed -i 's/^PasswordAuthentication\s\+yes/PasswordAuthentication no/' /etc/ssh/sshd_config" | |
$sh_c "sed -i 's/^#ClientAliveInterval\s\+0/ClientAliveInterval 30/' /etc/ssh/sshd_config" | |
$sh_c "sed -i 's/^#ClientAliveCountMax\s\+3/ClientAliveCountMax 3/' /etc/ssh/sshd_config" | |
$sh_c "sed -i 's/^#PubkeyAuthentication\s\+yes/PubkeyAuthentication yes/' /etc/ssh/sshd_config" | |
echo 'ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFoSZ2Rl49OtKKBgQF3pGfOnZL59N9pAnoSM2nMTwX5x hinako' >> ~/.ssh/authorized_keys | |
$sh_c "curl -Ls https://github.com/starship/starship/releases/latest/download/starship-x86_64-unknown-linux-musl.tar.gz | tar xz -C /usr/local/bin" | |
echo "$(starship init zsh)" >> .zshrc | |
# $sh_c "hostname $username" | |
# $sh_c "chmod 777 /etc/hostname /etc/hosts" | |
# $sh_c "sed -i \"s/$original/$username/g\" /etc/hosts" | |
# $sh_c "echo \"$username\" > /etc/hostname" | |
# $sh_c "chmod 644 /etc/hostname /etc/hosts" | |
pwd="$(cat /proc/sys/kernel/random/uuid || true)" | |
[ ! -z "$pwd" ] && $sh_c "echo root:$pwd | chpasswd" | |
# $sh_c "echo \"deb http://deb.debian.org/debian buster-backports main\" >> /etc/apt/sources.list" | |
# $sh_c 'apt-get update -qq >/dev/null' | |
# $sh_c 'apt-get install wireguard -y -qq >/dev/null' | |
# wg_key=$(wg genkey) | |
# wg_pub=$(echo $wg_key | wg pubkey) | |
# randint=$((RANDOM % 256)) | |
# itf=wg0 | |
# $sh_c "echo '[Interface]\nListenPort=2408\nPrivateKey=$wg_key\nAddress=10.10.3.$randint/32,fd02::$randint/128'" > /etc/wireguard/$itf.conf | |
# $sh_c "echo '[Peer]\nPublicKey=I6fP5QQge7sF5zEoy+kH0a6zsX1NKskglhoY3Jt6d0c=\nAllowedIPs=10.10.3.2/32,fd02::3/128'" >> /etc/wireguard/$itf.conf | |
# wg-quick up $itf | |
chsh -s /bin/zsh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment