Skip to content

Instantly share code, notes, and snippets.

@SajadJalilian
Created October 9, 2022 12:44
Show Gist options
  • Save SajadJalilian/d42dac21602c587e2eb30bbe0139cfa8 to your computer and use it in GitHub Desktop.
Save SajadJalilian/d42dac21602c587e2eb30bbe0139cfa8 to your computer and use it in GitHub Desktop.
PORT=443
UUID=$(cat /proc/sys/kernel/random/uuid)
sleep 3
PORT2=80
UUID2=$(cat /proc/sys/kernel/random/uuid)
IP=$(hostname -I | cut -d' ' -f1)
CONFIGNAME="config.json"
CONFIGNAME2="config2.json"
permissioncheck(){
ROOT_UID=0
if [[ $UID == $ROOT_UID ]]; then true ; else echo -e "You Must be the ROOT to Perfom this Task" ; exit 1 ; fi
}
# Permission Check
permissioncheck
echo "Run this script on external IP"
echo "Press Ctrl + C if you want to cancel the installation"
sleep 5
config(){
cat > docker-compose.yaml <<DOCKER
version: '3'
services:
v2ray:
image: v2fly/v2fly-core
restart: always
# network_mode: host
ports:
- $PORT:$PORT
environment:
- V2RAY_VMESS_AEAD_FORCED=false
volumes:
- ./$CONFIGNAME:/etc/v2ray/config.json:ro
v2ray2:
image: v2fly/v2fly-core
restart: always
# network_mode: host
ports:
- $PORT2:$PORT2
environment:
- V2RAY_VMESS_AEAD_FORCED=false
volumes:
- ./$CONFIGNAME2:/etc/v2ray/config.json:ro
DOCKER
cat > $CONFIGNAME <<CONFIG
{
"log": {
"loglevel": "info"
},
"inbounds": [
{
"port": $PORT,
"protocol": "vmess",
"allocate": {
"strategy": "always"
},
"settings": {
"clients": [
{
"id": "$UUID",
"level": 1,
"alterId": 0,
"email": "[email protected]"
}
],
"disableInsecureEncryption": true
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"connectionReuse": true,
"path": "/graphql"
},
"security": "none",
"tcpSettings": {
"header": {
"type": "http",
"response": {
"version": "1.1",
"status": "200",
"reason": "OK",
"headers": {
"Content-Type": [
"application/octet-stream",
"application/x-msdownload",
"text/html",
"application/x-shockwave-flash"
],
"Transfer-Encoding": ["chunked"],
"Connection": ["keep-alive"],
"Pragma": "no-cache"
}
}
}
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}
CONFIG
cat > $CONFIGNAME2 <<CONFIG
{
"log": {
"loglevel": "info"
},
"inbounds": [
{
"port": $PORT2,
"protocol": "vmess",
"allocate": {
"strategy": "always"
},
"settings": {
"clients": [
{
"id": "$UUID2",
"level": 1,
"alterId": 0,
"email": "[email protected]"
}
],
"disableInsecureEncryption": true
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"connectionReuse": true,
"path": "/graphql"
},
"security": "none",
"tcpSettings": {
"header": {
"type": "http",
"response": {
"version": "1.1",
"status": "200",
"reason": "OK",
"headers": {
"Content-Type": [
"application/octet-stream",
"application/x-msdownload",
"text/html",
"application/x-shockwave-flash"
],
"Transfer-Encoding": ["chunked"],
"Connection": ["keep-alive"],
"Pragma": "no-cache"
}
}
}
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": {}
}
]
}
CONFIG
}
# Update Repo & Install Docker &
# curl https://get.docker.com | sudo sh
# curl -SL https://github.com/docker/compose/releases/download/v2.11.1/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose
# sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
# # Run Service
# systemctl enable --now containerd
# systemctl enable --now docker
sleep 3
# Make Config
config
# Allow firewall
ufw allow $PORT
ufw allow $PORT2
# Start Docker Compose Service
sudo docker-compose up -d || printf "Pulling Failed \nMake sure your IP has access to the docker registry."
sleep 2
echo "! UUID : $UUID Port: $PORT"
echo "! Use Below Link for Import1:"
echo ""
# Vmess Link Generation
printf vmess://;echo \{\"add\":\"$IP\", \
\"aid\":\"0\", \
\"host\":\"\", \
\"id\":\"$UUID\", \
\"net\":\"ws\", \
\"path\":\"/graphql\", \
\"port\":\"$PORT\", \
\"ps\":\"v2ray\", \
\"tls\":\"\", \
\"type\":\"none\", \
\"v\":\"2\"\}|base64 -w0;echo
echo ""
echo "! After importing vmess link change the IP to your Internal Server IP"
echo ""
echo ""
echo "! UUID2 : $UUID2 Port2: $PORT2"
echo "! Use Below Link for Import:"
echo ""
# Vmess Link Generation
printf vmess://;echo \{\"add\":\"$IP\", \
\"aid\":\"0\", \
\"host\":\"\", \
\"id\":\"$UUID2\", \
\"net\":\"ws\", \
\"path\":\"/graphql\", \
\"port\":\"$PORT2\", \
\"ps\":\"v2ray\", \
\"tls\":\"\", \
\"type\":\"none\", \
\"v\":\"2\"\}|base64 -w0;echo
echo ""
echo "! After importing vmess link change the IP to your Internal Server IP"
# Clean Up
#rm -rf deploy.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment