-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
182 lines (159 loc) · 5.6 KB
/
index.html
File metadata and controls
182 lines (159 loc) · 5.6 KB
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
#!/bin/bash
red='\033[0;31m'
green='\033[0;32m'
yellow='\033[0;33m'
plain='\033[0m'
set -e
echoLog (){
if [[ $1 == "INFO" ]]; then
echo -e "${green}[INFO]${plain} $2"
elif [[ $1 == "ERROR" ]]; then
echo -e "${red}[ERROR]${plain} $2"
elif [[ $1 == "WARN" ]]; then
echo -e "${yellow}[WARN]${plain} $2"
elif [[ $1 == "RED" ]]; then
echo -e "${red}$2${plain}"
elif [[ $1 == "GREEN" ]]; then
echo -e "${green}$2${plain}"
elif [[ $1 == "YELLOW" ]]; then
echo -e "${yellow}$2${plain}"
fi
}
# Check if user is root
[ $(id -u) != "0" ] && { echoLog ERROR "You must be root to run this script"; exit 1; }
if [ -z "$1" ] ;then
echoLog ERROR "You must specify a hostname, like:"
echoLog GREEN "curl -sSL https://deploy.fornax.network | sudo bash -s [hostname]"
exit
fi
# Hostname
sid=$1
echoLog INFO "Setting up hostname ecs-$sid.fornax.network..."
hostname "ecs-$sid.fornax.network"
echo -e "ecs-$sid.fornax.network" > /etc/hostname
sed -i "s/$HOSTNAME/ecs-$sid.fornax.network/g" /etc/hosts
echoLog INFO "Hostname Done."
# BBR
echoLog INFO "Setting up BBR..."
param=$(sysctl net.ipv4.tcp_congestion_control | awk '{print $3}')
if [[ x"${param}" == x"bbr" ]]; then
echoLog WARN "TCP BBR has already been installed. nothing to do..."
else
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
echo "net.core.default_qdisc = fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr" >> /etc/sysctl.conf
sysctl -p >/dev/null 2>&1
fi
echoLog INFO "BBR Done."
# SWAP
echoLog INFO "Setting up SWAP..."
if [ -e /swap ] || [ -e /swapfile ]
then
echoLog WARN "SWAP has already been installed. nothing to do..."
else
dd if=/dev/zero of=/swap bs=1M count=1024
chmod 0600 /swap
mkswap /swap
swapon /swap
echo '/swap none swap defaults 0 0' >> /etc/fstab
fi
echoLog INFO "SWAP Done."
# Docker
echoLog INFO "Setting up Docker..."
sudo apt install -y \
apt-transport-https \
ca-certificates \
curl \
software-properties-common \
git
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt update
sudo apt install docker-ce -y
sudo docker version
# get latest docker compose
# THX https://gist.github.com/deviantony/2b5078fe1675a5fedabf1de3d1f2652a
COMPOSE_VERSION=$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep 'tag_name' | cut -d\" -f4)
echoLog INFO "Lastest Docker Compose version: $COMPOSE_VERSION"
sudo curl -L "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
echoLog INFO "Docker Done."
# 1Password
ONEPASSWORD_VERSION='v0.5.7'
echoLog INFO "Setting up 1Password CLI"
sudo apt install curl jq pwgen gnupg unzip -y|| exit $?
mkdir -p /usr/local/bin
chmod 755 /usr/local/bin
sudo curl -fSL "https://cache.agilebits.com/dist/1P/op/pkg/${ONEPASSWORD_VERSION}/op_linux_amd64_${ONEPASSWORD_VERSION}.zip" -o op.zip
sudo unzip ~/op.zip -d /usr/local/bin -x op.sig && rm -rf ~/op.zip
op --version
# logrotate
echoLog INFO "Setting up logrotate..."
cat > /etc/logrotate_nginx.conf <<EOL
/opt/nginx/log/*/nginx.log {
daily
rotate 365
compress
delaycompress
dateyesterday
dateext
create
missingok
notifempty
sharedscripts
postrotate
docker inspect -f '{{ .State.Pid }}' nginx | xargs kill -USR1
endscript
}
EOL
crontab -l | { cat; echo "0 0 * * * /usr/sbin/logrotate --force /etc/logrotate_nginx.conf"; } | crontab -
echoLog INFO "logrotate Done."
# Ketchum
echoLog INFO "Setting up Ketchum..."
useradd Ketchum
chage -d 0 Ketchum
passwd -d Ketchum
mkdir /home/Ketchum/.ssh/ -p
sudo curl -LN "https://github.com/FSPNet/Ketchum/raw/master/authorized_keys" -o /home/Ketchum/.ssh/authorized_keys
chown Ketchum:Ketchum /home/Ketchum -R
chmod 644 /home/Ketchum/.ssh/authorized_keys
echo "Ketchum ALL=(ALL:ALL) NOPASSWD :ALL" >> /etc/sudoers
echoLog INFO "User Done."
# SSH
echoLog INFO " Setting up SSH..."
if [ -z "`grep ^Port /etc/ssh/sshd_config`" ]; then
sed -i "s@^#Port.*@&\nPort 13613@" /etc/ssh/sshd_config
elif [ -n "`grep ^Port /etc/ssh/sshd_config`" ]; then
sed -i "s@^Port.*@Port 13613@" /etc/ssh/sshd_config
fi
sudo sed -i "s@^#PasswordAuthentication.*@&\nPasswordAuthentication no@" /etc/ssh/sshd_config
systemctl restart ssh
echoLog INFO "SSH Done."
# thefuck
echoLog INFO " Setting up thefuck..."
sudo apt install python-setuptools -y
sudo apt install thefuck -y
# autojump
echoLog INFO " Setting up autojump..."
sudo apt install autojump -y
# ZSH
echoLog INFO " Setting up ZSH..."
sudo apt install zsh -y
git clone https://github.com/robbyrussell/oh-my-zsh.git /home/Ketchum/.oh-my-zsh
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git /home/Ketchum/.oh-my-zsh/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions /home/Ketchum/.oh-my-zsh/plugins/zsh-autosuggestions
sudo curl -LN "https://github.com/FSPNet/Pikachu/raw/master/conf/.zshrc" -o /home/Ketchum/.zshrc
sudo sed -i "s@/home/Ketchum:/bin/sh@/home/Ketchum:/bin/zsh@" /etc/passwd
# Other
echo 'soft nofile 65535\nhard nofile 65535' >> /etc/security/limits.conf
sudo curl -LN "https://github.com/FSPNet/Pikachu/raw/master/conf/sysctl.conf" -o /etc/sysctl.conf
sudo sysctl --system
echoLog INFO "INIT Done."
echoLog RED "DON'T FORGET DEL DEFAULT USER"
exit 0;