diff --git a/cloud-init.yml b/cloud-init.yml new file mode 100644 index 000000000..520f75d0a --- /dev/null +++ b/cloud-init.yml @@ -0,0 +1,21 @@ +#cloud-config +package_upgrade: true +packages: + - apt-transport-https + - ca-certificates + - curl + - wget + - gnupg-agent + - software-properties-common + - git +runcmd: + - cd /opt + - git clone https://github.com/hiddify/hiddify-config/ + - cd hiddify-config + - echo "USER_SECRET=44da16ea20ff4bac92afae43ef97f067" >config.env + - echo "MAIN_DOMAIN=example.com" >>config.env + - bash install.sh + +power_state: + mode: reboot + message: please open https://example.com/44da16ea20ff4bac92afae43ef97f067 \ No newline at end of file diff --git a/config.env b/config.env index 06209a386..fba9e0953 100644 --- a/config.env +++ b/config.env @@ -4,5 +4,6 @@ USER_SECRET= # 32 hex secret for user MAIN_DOMAIN= # a subdomain or main domain that is pointed to your server -CDN_NAME=ar #ar=arvancloud or cf=cloudflare ; if your are not using cdn enter 'ar' + +# Optional: TELEGRAM_AD_TAG= # AD TAG for telegram proxy diff --git a/install.sh b/install.sh index ed03fa4b7..46c889110 100755 --- a/install.sh +++ b/install.sh @@ -55,9 +55,12 @@ function check_for_env() { random_secret=$(hexdump -vn16 -e'4/4 "%08X" 1 "\n"' /dev/urandom) replace_empty_env USER_SECRET "please enter 32 char user secret" $random_secret "^([0-9A-Fa-f]{32})$" - replace_empty_env MAIN_DOMAIN "please enter valid domain name to use " "www.example.com" "^([A-Za-z0-9\.]+\.[a-zA-Z]{2,})$" - DOMAIN_IP=$(dig +short -t a $MAIN_DOMAIN.) SERVER_IP=$(curl -Lso- https://api.ipify.org) + replace_empty_env MAIN_DOMAIN "please enter valid domain name to use " "$SERVER_IP.nip.io" "^([A-Za-z0-9\.]+\.[a-zA-Z]{2,})$" + + + DOMAIN_IP=$(dig +short -t a $MAIN_DOMAIN.) + echo "resolving domain $MAIN_DOMAIN -> IP= $DOMAIN_IP ServerIP-> $SERVER_IP" if [[ $SERVER_IP != $DOMAIN_IP ]];then @@ -85,7 +88,7 @@ function replace_empty_env() { echo "Enter $DEFAULT (default value='$DEFAULT' -> to confirm enter)" fi - read -p "> " RESPONSE + # read -p "> " RESPONSE if [[ -z "$RESPONSE" ]]; then RESPONSE=$DEFAULT fi