sh vps初始化

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh vps初始化相关的知识,希望对你有一定的参考价值。

#!/bin/bash

SERVER_IP=`ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'`

# update & upgrade 
apt update && apt upgrade -y 

# install shadowsocks 
apt install -y shadowsocks 

# write shadowsocks config
cat > /root/config.json <<EOF
{
    "server":"$SERVER_IP",  
    "server_port":8388,
    "local_address":"127.0.0.1",
    "local_port":1080,
    "password":"password++--",
    "method":"aes-256-cfb"
}
EOF


# set autostart 
ln -fs /lib/systemd/system/rc-local.service /etc/systemd/system/rc-local.service
cat > /etc/systemd/system/rc-local.service <<EOF

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.

# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

[Install]
WantedBy=multi-user.target
Alias=rc-local.service
EOF

cat > /etc/rc.local <<EOF
#!/bin/bash

/usr/bin/ssserver -c /root/config.json -d start
EOF

chmod 755 /etc/rc.local

# turn on bbr 
wget https://gist.githubusercontent.com/xinali/a738fe13a5483fb40d7d727c617b7da3/raw/da273105c6f12cfd2b23508da0663d9c2a2cdb46/ubuntu_enable_bbr.sh
bash ubuntu_enable_bbr.sh 

以上是关于sh vps初始化的主要内容,如果未能解决你的问题,请参考以下文章

sh start_vps.sh

sh vps__openvpn_install.sh

sh 新的VPS设置

sh vps安装

sh VPS服务器 - 设置 - Centos的

sh 备份vps文件到qiniu kodo