add *upgrade* command; restrict logging

This commit is contained in:
Evgeny Nerush
2023-10-27 14:15:09 +03:00
parent 7604952e36
commit 435b936aa2
3 changed files with 39 additions and 30 deletions

57
ex.sh
View File

@@ -7,6 +7,7 @@ green='\033[0;32m'
yellow='\033[0;33m' yellow='\033[0;33m'
normal='\033[0m' normal='\033[0m'
export PATH=$PATH:/usr/local/bin/ # for sudo user this can be not in PATH
if command -v xray > /dev/null if command -v xray > /dev/null
then then
xray_version=$(xray --version | head -n 1 | cut -c 6-10) xray_version=$(xray --version | head -n 1 | cut -c 6-10)
@@ -41,15 +42,15 @@ if [ $command = "install" ]
then then
echo -e "${bold}Download and install xray?${normal} (Y/n)" echo -e "${bold}Download and install xray?${normal} (Y/n)"
read answer read answer_di
if [ -v $answer ] || [ $(echo $answer | cut -c 1) != "n" ] if [ -v $answer_di ] || [ $(echo $answer_di | cut -c 1) != "n" ]
then then
install_xray=true install_xray=true
if command -v xray > /dev/null if command -v xray > /dev/null
then then
echo -e "xray ${version} detected, install anyway? (y/N)" echo -e "xray ${version} detected, install anyway? (y/N)"
read answer read answer_ia
if [ -v $answer ] || ([ $(echo $answer | cut -c 1) != "y" ] && [ $(echo $answer | cut -c 1) != "Y" ]) if [ -v $answer_ia ] || ([ $(echo $answer_ia | cut -c 1) != "y" ] && [ $(echo $answer_ia | cut -c 1) != "Y" ])
then then
install_xray=false install_xray=false
fi fi
@@ -60,6 +61,8 @@ then
then then
if bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install if bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install
then then
mkdir -p /var/log/xray
touch /var/log/xray/error.log
echo -e "${green}xray installed${normal}" echo -e "${green}xray installed${normal}"
else else
echo -e "${red}xray not installed, something goes wrong${normal}" echo -e "${red}xray not installed, something goes wrong${normal}"
@@ -73,8 +76,8 @@ to install xray${normal}"
fi fi
echo -e "${bold}Generate configs?${normal} (Y/n)" echo -e "${bold}Generate configs?${normal} (Y/n)"
read answer read answer_gc
if [ -v $answer ] || [ $(echo $answer | cut -c 1) != "n" ] if [ -v $answer_gc ] || [ $(echo $answer_gc | cut -c 1) != "n" ]
then then
if ! $(command -v xray > /dev/null) if ! $(command -v xray > /dev/null)
then then
@@ -205,33 +208,32 @@ elif [ $command = "del" ]
then then
echo -e "TODO" echo -e "TODO"
elif [ $command = "mimic" ]
then
echo -e "TODO"
elif [ $command = "upgrade" ] elif [ $command = "upgrade" ]
then then
echo -e "TODO" if bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install
then
echo -e "${green}xray upgraded${normal}"
else
echo -e "${red}xray not upgraded${normal}"
fi
elif [ $command = "remove" ] elif [ $command = "remove" ]
then then
echo -e "Remove xray? (y/N)" echo -e "Remove xray? (y/N)"
read answer read answer_rx
if [ ! -v $answer ] && ([ $(echo $answer | cut -c 1) = "y" ] || [ $(echo $answer | cut -c 1) = "Y" ]) if [ ! -v $answer_rx ] && ([ $(echo $answer_rx | cut -c 1) = "y" ] || [ $(echo $answer_rx | cut -c 1) = "Y" ])
then then
echo -e "${red}Please type YES to remove${normal}" echo -e "${red}Please type YES to remove${normal}"
read answer read answer_y
if [ ! -v $answer ] && ([ $answer = "YES" ] || [ $answer = "yes" ]) if [ ! -v $answer_y ] && ([ $answer_y = "YES" ] || [ $answer_y = "yes" ])
then then
if $is_root if $is_root
then then
if bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ remove --purge if bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ remove --purge
then then
echo -e " echo -e "${green}xray removed${normal}"
${green}xray removed${normal}"
else else
echo -e " echo -e "${red}xray not removed${normal}"
${red}xray not removed${normal}"
fi fi
else else
echo -e "${red}You should be root, or run this script with sudo echo -e "${red}You should be root, or run this script with sudo
@@ -251,11 +253,10 @@ Here is the list of all available commands:
${bold}help${normal} show this message (default) ${bold}help${normal} show this message (default)
${bold}install${normal} run interactive prompt, which asks to download and install ${bold}install${normal} run interactive prompt, which asks to download and install
XRay and generate configs for server and client; XRay and generate configs for server and client
${bold}add ${underl}username${normal} add user with (any, fake) username to configs ${bold}add ${underl}username${normal} add user with (any, fake) username to configs
${bold}del ${underl}username${normal} delete user with given username from configs ${bold}del ${underl}username${normal} delete user with given username from configs
${bold}mimic ${underl}site${normal} change site xray server imitates ${bold}upgrade${normal} upgrade xray, do not touch configs
${bold}upgrade${normal} upgrade xray and configs
${bold}remove${normal} remove xray" ${bold}remove${normal} remove xray"
fi fi
@@ -263,11 +264,17 @@ echo -e "
Command is done. Command is done.
${red}Important:${normal} It is assumed that configs are stored and updated ${red}Important:${normal} It is assumed that configs are stored and updated
locally as config_server.json and config_client_username.json files. locally as config_server.json, config_client.json or
You should manually start XRay with one of configs, depending config_client_username.json files. You should manually
start XRay with one of configs, depending
which role - server or client - XRay should play: which role - server or client - XRay should play:
sudo cp config_(role).json /usr/local/etc/xray/config.json sudo cp config_(role).json /usr/local/etc/xray/config.json
sudo systemctl start xray sudo systemctl start xray
or or
sudo xray run -c config_(role).json" sudo xray run -c config_(role).json
${red}Important:${normal} Only warnings and errors are logged
by xray for current configs. For logs, see stdout or try
journalctl -u xray
"

View File

@@ -1,8 +1,9 @@
{ {
"log": { "log": {
"access": "", "access": "none",
"error": "", "error": "",
"loglevel": "info" "loglevel": "warning",
"dnsLog": false
}, },
"inbounds": [ "inbounds": [
{ {

View File

@@ -1,8 +1,9 @@
{ {
"log": { "log": {
"access": "/var/log/xray/access.log", "access": "none",
"error": "/var/log/xray/error.log", "error": "",
"loglevel": "info" "loglevel": "warning",
"dnsLog": false
}, },
"routing": { "routing": {
"domainStrategy": "IPIfNonMatch", "domainStrategy": "IPIfNonMatch",