Compare commits

..

No commits in common. "efd06a9322561051ec84d30a4acf46fa64a18201" and "6b4472db046ecdc0ce4d74ce98bddf17dcaae1f6" have entirely different histories.

3 changed files with 17 additions and 45 deletions

View File

@ -3,20 +3,17 @@
# NOTE: re-run this if the IP/PORT change... # NOTE: re-run this if the IP/PORT change...
# #
ENDPOINT=${ENDPOINT}
ENDPOINT_PORT=${ENDPOINT_PORT}
# get the current IP... # get the current IP...
HOST_IP=$(ip addr show dev lan \ HOST=$(ip addr show dev lan \
| grep 'inet ' \ | grep 'inet ' \
| cut -d ' ' -f 6 \ | cut -d ' ' -f 6 \
| cut -d '/' -f 1) | cut -d '/' -f 1)
PORT=5555
ENCRYPTION=aes-256-gcm ENCRYPTION=aes-256-gcm
USER=shadowsocks USER=shadowsocks
SCRIPT=shadowsocks SCRIPT=shadowsocks
SERVER_CONFIG=shadowsocks-server.config CONFIG=shadowsocks.config
CLIENT_CONFIG=shadowsocks-client.config
# System and dependencies... # System and dependencies...
@ -44,8 +41,8 @@ cd /home/$USER
# get/generate password... # get/generate password...
if [ -e /home/$USER/$SERVER_CONFIG ] ; then if [ -e /home/$USER/$CONFIG ] ; then
PASSWD=$(cat /home/$USER/$SERVER_CONFIG \ PASSWD=$(cat /home/$USER/$CONFIG \
| grep password \ | grep password \
| cut -d '"' -f 4) | cut -d '"' -f 4)
else else
@ -53,36 +50,25 @@ else
fi fi
# /home/$USER/$SERVER_CONFIG # /home/$USER/$CONFIG
cat > $SERVER_CONFIG << EOF cat > $CONFIG << EOF
{ {
"server": "${HOST_IP}", "server": "${HOST}",
"server_port": 8388, "server_port": ${PORT},
"password": "${PASSWD}", "password": "${PASSWD}",
"method": "${ENCRYPTION}" "method": "${ENCRYPTION}"
} }
EOF EOF
chown $USER:$USER $SERVER_CONFIG chown $USER:$USER $CONFIG
chmod 600 $SERVER_CONFIG chmod 600 $CONFIG
# /home/$USER/$CLIENT_CONFIG
cat > $CLIENT_CONFIG << EOF
{
"server": "${ENDPOINT}",
"server_port": ${ENDPOINT_PORT},
"password": "${PASSWD}",
"method": "${ENCRYPTION}"
"local_address": "127.0.0.1",
"local_port": 1080
}
EOF
# /home/$USER/$SCRIPT # /home/$USER/$SCRIPT
cat > $SCRIPT << EOF cat > $SCRIPT << EOF
#!/sbin/openrc-run #!/sbin/openrc-run
command="ssserver" command="ssserver"
command_args="-c /home/$USER/$SERVER_CONFIG" command_args="-c /home/$USER/$CONFIG"
command_user=$USER command_user=$USER
pidfile="/run/\$SVCNAME.pid" pidfile="/run/\$SVCNAME.pid"

View File

@ -38,23 +38,11 @@ LAN_GATE=SKIP
REBOOT=${REBOOT:=1} REBOOT=${REBOOT:=1}
USER=shadowsocks
# Wireguard config...
DFL_ENDPOINT=${DFL_ENDPOINT:=$(\
which dig > /dev/null 2>&1 \
&& (dig +short ${DOMAIN:-$DFL_DOMAIN} \
| tail -1) \
|| echo "${DOMAIN:-$DFL_DOMAIN}")}
xread "Shadowsocks endpoint: " ENDPOINT
DFL_ENDPOINT_PORT=${DFL_ENDPOINT_PORT:=5555}
xread "Shadowsocks endpoint port: " ENDPOINT_PORT
readVars readVars
USER=shadowsocks
#---------------------------------------------------------------------- #----------------------------------------------------------------------
@ -70,7 +58,7 @@ OPTS_STAGE_2="\
#---------------------------------------------------------------------- #----------------------------------------------------------------------
echo "# Building config..." echo "# Building config..."
buildAssets ENDPOINT ENDPOINT_PORT buildAssets
echo "# Creating CT..." echo "# Creating CT..."
pctCreateAlpine $ID "$PASS" pctCreateAlpine $ID "$PASS"
@ -80,7 +68,7 @@ echo "# Installing dependencies..."
sed \ sed \
-e '/v3\.\d*/{p;s|v3\.\d*|edge|}' \ -e '/v3\.\d*/{p;s|v3\.\d*|edge|}' \
-i /etc/apk/repositories -i /etc/apk/repositories
@ lxc-attach $ID apk add bash libqrencode logrotate shadowsocks-rust @ lxc-attach $ID apk add bash logrotate shadowsocks-rust
echo "# Copying assets..." echo "# Copying assets..."
@ -91,8 +79,6 @@ echo "# Generating/updating config and server script..."
@ lxc-attach $ID bash /root/update-shadowsocks.sh @ lxc-attach $ID bash /root/update-shadowsocks.sh
echo "# Profile: $*"
echo "# Post config..." echo "# Post config..."
pctSet $ID "${OPTS_STAGE_2}" $REBOOT pctSet $ID "${OPTS_STAGE_2}" $REBOOT
pctSetNotes $ID pctSetNotes $ID

View File

@ -10,4 +10,4 @@ tcp:
${CTHOSTNAME}: ${CTHOSTNAME}:
loadBalancer: loadBalancer:
servers: servers:
- address: ${CTHOSTNAME}.srv:8388 - address: ${CTHOSTNAME}.srv:5555