Last active
July 23, 2019 06:32
-
-
Save ihipop/958ac0002852ddaccad683b0ad36d6fd to your computer and use it in GitHub Desktop.
SSR-manyuser None Auto Script for Ubuntu 16.04 LTS Only
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
#!/bin/bash | |
set -eu | |
install_dir=${install_dir:-'/opt/ihipop/'} | |
run_user=${run_user:-'www-data'} | |
[[ "${install_dir}" = "" || "${install_dir}" = "/" ]] && { echo install_dir ${install_dir} is not Valid ;exit 1;} | |
function trim() { | |
local var="$*" | |
# remove leading whitespace characters | |
var="${var#"${var%%[![:space:]]*}"}" | |
# remove trailing whitespace characters | |
var="${var%"${var##*[![:space:]]}"}" | |
echo -n "$var" | |
} | |
function install_brook() { | |
local install_dir="`readlink -f ${install_dir}`""/brook/" | |
mkdir -p ${install_dir} | |
chown ${run_user}.${run_user} ${install_dir} | |
cd ${install_dir} | |
local BROOK_BINARY=${BROOK_BINARY:-'https://github.com/txthinking/brook/releases/download/v20190601/brook'} | |
wget "${BROOK_BINARY}" -O brook_linux | |
chmod +x ./brook_linux | |
setcap 'cap_net_bind_service=+ep' ./brook_linux | |
local BROOK_OPTIONS=${BROOK_OPTIONS:-"servers -l ':7008 password1' -l ':31002 password2'"} | |
cat << EOF > /etc/supervisor/conf.d/brook.conf | |
[program:brook_linux] | |
directory=${install_dir} | |
command=${install_dir}/brook_linux ${BROOK_OPTIONS} | |
user=${run_user} | |
autostart=true | |
#redirect_stderr = true | |
EOF | |
update_supervisor | |
} | |
function update_supervisor() { | |
supervisorctl update | |
supervisorctl status | |
} | |
function install_shadowsocksR() { | |
local install_dir="`readlink -f ${install_dir}`""/shadowsocksr/" | |
apt-get install libsodium18 --yes | |
setcap 'cap_net_bind_service=+ep' $(readlink -f $(which python)) | |
mkdir -p ${install_dir} | |
chown ${run_user}.${run_user} ${install_dir} | |
cd ${install_dir} | |
local SSR_REPO=${SSR_REPO:-'https://github.com/shadowsocksr-backup/shadowsocksr.git'} | |
sudo -Hu ${run_user} git clone -b manyuser "${SSR_REPO}" ${install_dir} | |
cd $install_dir | |
bash initcfg.sh | |
touch mudb.json | |
chown ${run_user}.${run_user} ${install_dir}/* | |
sed -i -r "s#API_INTERFACE\s*=.*['\"]#API_INTERFACE = 'mudbjson' \#\# #" userapiconfig.py | |
cat << EOF > /etc/supervisor/conf.d/ssr-manyuser.conf | |
[program:ssr-manyuser] | |
directory=${install_dir} | |
command=python -u server.py m | |
user=${run_user} | |
autostart=true | |
#redirect_stderr = true | |
EOF | |
echo do "python mujson_mgr.py -a -u username -p 8000 -k password -m chacha20 -O auth_sha1_v4 -o http_simple" at "$install_dir" manully | |
local DEFAULT_SSR_COMMAND=${DEFAULT_SSR_COMMAND:-"-a -u demo_seucre -p 443 -k demo_seucre_password -m chacha20-ietf -O auth_aes128_md5 -o tls1.2_ticket_auth"} | |
python mujson_mgr.py $DEFAULT_SSR_COMMAND | |
update_supervisor | |
} | |
function init_supervisor() { | |
apt-get install git supervisor libcap2-bin --yes | |
echo 'warging: Need to change `minfds` in supervisord config file' | |
mkdir -p /etc/systemd/system/supervisor.service.d; | |
cat << EOF >/etc/systemd/system/supervisor.service.d/override.conf | |
[Service] | |
LimitNOFILE=infinity | |
LimitMEMLOCK=infinity | |
EOF | |
systemctl daemon-reload | |
systemctl enable supervisor | |
systemctl start supervisor | |
} | |
init_supervisor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install
wget https://gist.github.com/ihipop/958ac0002852ddaccad683b0ad36d6fd/raw/ -O init.bash source ./init.bash install_shadowsocksR install_brook
ENV
BROOK_OPTIONS
DEFAULT_SSR_COMMAND
install_dir
run_user