81 lines
2.5 KiB
Bash
81 lines
2.5 KiB
Bash
|
#!/bin/bash
|
||
|
|
||
|
set -e
|
||
|
|
||
|
SERVER_ADDRESS=47.107.32.69
|
||
|
USER=root
|
||
|
|
||
|
function update() {
|
||
|
echo "start update packages"
|
||
|
|
||
|
ssh "$USER@$SERVER_ADDRESS" <<EOF
|
||
|
apt update
|
||
|
apt upgrade -y
|
||
|
EOF
|
||
|
|
||
|
echo "update packages finished."
|
||
|
}
|
||
|
|
||
|
function init() {
|
||
|
echo "start deploy server"
|
||
|
|
||
|
scp resource/openresty.service $USER@$SERVER_ADDRESS:/lib/systemd/system/openresty.service
|
||
|
scp resource/frps.service $USER@$SERVER_ADDRESS:/etc/systemd/system/frps.service
|
||
|
|
||
|
ssh "$USER@$SERVER_ADDRESS" <<EOF
|
||
|
if command -v openresty > /dev/null 2>&1; then
|
||
|
echo "OpenResty has installed."
|
||
|
else
|
||
|
apt -y install --no-install-recommends wget gnupg ca-certificates lsb-release
|
||
|
wget -O - https://openresty.org/package/pubkey.gpg | gpg --dearmor -o /usr/share/keyrings/openresty.gpg
|
||
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/openresty.gpg] http://openresty.org/package/ubuntu $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/openresty.list > /dev/null
|
||
|
apt update
|
||
|
apt -y install openresty
|
||
|
opm get bungle/lua-resty-session
|
||
|
fi
|
||
|
|
||
|
if [ ! -f /root/Server/frp_0.60.0_linux_amd64/frps ]; then
|
||
|
# wget https://github.com/fatedier/frp/releases/download/v0.60.0/frp_0.60.0_linux_amd64.tar.gz
|
||
|
wget https://frp-by1.wwvvww.cn:44048/s/frps/download -O frp_0.60.0_linux_amd64.tar.gz
|
||
|
tar xvf ./frp_0.60.0_linux_amd64.tar.gz
|
||
|
fi
|
||
|
|
||
|
if command -v docker &> /dev/null; then
|
||
|
echo "docker has installed."
|
||
|
else
|
||
|
install -m 0755 -d /etc/apt/keyrings
|
||
|
curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
|
||
|
chmod a+r /etc/apt/keyrings/docker.asc
|
||
|
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
|
||
|
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
|
||
|
tee /etc/apt/sources.list.d/docker.list > /dev/null
|
||
|
apt-get update
|
||
|
apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
|
||
|
fi
|
||
|
|
||
|
if [ ! -d /root/Server ]; then
|
||
|
mkdir -p /root/Server /root/Server/logs
|
||
|
fi
|
||
|
EOF
|
||
|
|
||
|
echo "update packages finished."
|
||
|
}
|
||
|
|
||
|
function main() {
|
||
|
local cmd=$1
|
||
|
shift 1
|
||
|
case $cmd in
|
||
|
update)
|
||
|
update
|
||
|
;;
|
||
|
init)
|
||
|
init
|
||
|
;;
|
||
|
*)
|
||
|
build
|
||
|
;;
|
||
|
esac
|
||
|
}
|
||
|
|
||
|
main $@
|