Skip to content

Commit

Permalink
fully automated setup
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Dec 7, 2022
1 parent d59fc64 commit 703d685
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
21 changes: 21 additions & 0 deletions cloud-init.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 2 additions & 1 deletion config.env
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 6 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 703d685

Please sign in to comment.