Skip to content

Instantly share code, notes, and snippets.

@benzBrake
Last active July 26, 2020 09:10
Show Gist options
  • Select an option

  • Save benzBrake/c0f8a395340a9540b465d6cedaa3749a to your computer and use it in GitHub Desktop.

Select an option

Save benzBrake/c0f8a395340a9540b465d6cedaa3749a to your computer and use it in GitHub Desktop.
#!/bin/bash
SH_PATH=$(cd "$(dirname "$0")";pwd)
cd ${SH_PATH}
if [ ! -z "$(command -v yum)" ]; then
yum -y install wget expect
if [ ! -f "/etc/yum.repos.d/cloudfoundry-cli.repo" ]; then
wget -O /etc/yum.repos.d/cloudfoundry-cli.repo https://packages.cloudfoundry.org/fedora/cloudfoundry-cli.repo
fi
yum -y install cf-cli
elif [ ! -z "$(command -v apt-get)" ]; then
apt-get update && apt-get upgrade -y && apt-get install -y apt-transport-https wget
if [ ! -f "/etc/apt/sources.list.d/cloudfoundry-cli.list" ]; then
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | apt-key add -
echo "deb http://packages.cloudfoundry.org/debian stable main" > /etc/apt/sources.list.d/cloudfoundry-cli.list
fi
else
echo "不支持你的小鸡"
exit
fi
echo "进行配置 。。。"
read -p "请输入你的应用名称:" PI_APP_NAME
echo "应用名称:${PI_APP_NAME}"
read -p "请输入你的应用内存大小(默认256):" PI_MEM_SIZE
if [ -z "${PI_MEM_SIZE}" ];then
PI_MEM_SIZE=256
fi
echo "内存大小:${PI_MEM_SIZE}"
echo "开始登陆 Pivotal"
cf login -a https://api.run.pivotal.io
echo "开始配置 APP"
if [ ! -d "${SH_PATH}/v2ray-cloudfoundry/" ]; then
git clone https://github.com/badafans/v2ray-cloudfoundry.git
fi
chmod +x ${SH_PATH}/v2ray-cloudfoundry/v2ray/*
PI_UUID="$(cat /proc/sys/kernel/random/uuid)"
sed -i "s#.*\"id\".*# \"id\": \"${PI_UUID}\",#" ${SH_PATH}/v2ray-cloudfoundry/v2ray/config.json
cat > ${SH_PATH}/v2ray-cloudfoundry/manifest.yml << EOF
applications:
- path: .
name: ${PI_APP_NAME}
random-route: true
memory: ${PI_MEM_SIZE}M
EOF
echo "配置完成。"
echo "进行安装。。。"
cd ${SH_PATH}/v2ray-cloudfoundry
cf push
PI_ADDR=$(cf apps | grep ${PI_APP_NAME} | awk '{print $6}')
cat > /tmp/client.json <<EOF
{
"v": "2",
"ps": "PivotalYES",
"add": "${PI_ADDR}",
"port": "4443",
"id": "${PI_UUID}",
"aid": "64",
"net": "ws",
"type": "none",
"host": "",
"path": "",
"tls": "tls",
"allowInsecure": "true"
}
EOF
PI_VMESS=$(cat /tmp/client.json | base64)
cf logout
echo "安装完成。你的 PivotalYes地址为"
echo vmess://${PI_VMESS}
uname -r | grep microsoft > /dev/null
if [ $? -eq 0 ]; then
echo vmess://${PI_VMESS} | clip.exe
echo "链接已经复制到剪贴板"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment