mirror of
https://github.com/EtherDream/jsproxy
synced 2024-11-22 18:50:48 +00:00
108 lines
2.1 KiB
Bash
Executable File
108 lines
2.1 KiB
Bash
Executable File
source ./dnsconf
|
|
|
|
svc_port=443
|
|
|
|
acme_args="-d $DOMAIN -d *.$DOMAIN -d *.ext.$DOMAIN"
|
|
js_arr_items=""
|
|
|
|
ngx_vhost_rhost="\
|
|
*.ext.$DOMAIN \$_vhost_dec_ext;
|
|
|
|
"
|
|
ngx_rhost_vhost="\
|
|
default \$_rhost_enc_ext.ext.$DOMAIN;
|
|
|
|
"
|
|
|
|
while read alias host
|
|
do
|
|
[ -z "$host" ] && continue
|
|
|
|
acme_args+=" -d *.$alias.$DOMAIN"
|
|
js_arr_items+=" ['$alias', '$host'],
|
|
"
|
|
# rhost to vhost map
|
|
dot_str=${host//[^.]}
|
|
dot_num=${#dot_str}
|
|
|
|
ngx_rhost_vhost+="\
|
|
$host $alias.$DOMAIN;
|
|
www.$host www.$alias.$DOMAIN;
|
|
*.$host \$_rhost_slice_$dot_num.$alias.$DOMAIN;
|
|
|
|
"
|
|
# vhost to rhost map
|
|
dot_str=${alias//[^.]}
|
|
dot_num=${#dot_str}
|
|
|
|
ngx_vhost_rhost+="\
|
|
$alias.$DOMAIN $host;
|
|
www.$alias.$DOMAIN www.$host;
|
|
*.$alias.$DOMAIN \$_vhost_slice_$dot_num.$host;
|
|
|
|
"
|
|
done < sitelist.txt
|
|
|
|
|
|
# gen nginx conf
|
|
echo "$ngx_vhost_rhost" > ./server/include/vhost-rhost.map
|
|
echo "$ngx_rhost_vhost" > ./server/include/rhost-vhost.map
|
|
|
|
echo "\
|
|
server_name $DOMAIN;
|
|
listen $svc_port ssl;" > ./server/include/host-root.conf
|
|
|
|
echo "\
|
|
server_name *.$DOMAIN;
|
|
listen $svc_port ssl;" > ./server/include/host-wild.conf
|
|
|
|
echo "\
|
|
ssl_certificate cert/${DOMAIN}.fullchain.rsa.cer;
|
|
ssl_certificate_key cert/${DOMAIN}.rsa.key;
|
|
|
|
ssl_certificate cert/${DOMAIN}.fullchain.ecc.cer;
|
|
ssl_certificate_key cert/${DOMAIN}.ecc.key;
|
|
" > ./server/include/cert.conf
|
|
|
|
echo "\
|
|
return 200 'importScripts(\"//${DOMAIN}/x.js\")';
|
|
" > ./server/include/x-js.conf
|
|
|
|
|
|
# gen ssl cert
|
|
ACME=~/.acme.sh/acme.sh
|
|
|
|
$ACME \
|
|
--issue \
|
|
--dns $DNS_ID \
|
|
$acme_args
|
|
|
|
$ACME \
|
|
--issue \
|
|
--dns $DNS_ID \
|
|
$acme_args \
|
|
--keylength ec-256
|
|
|
|
|
|
$ACME \
|
|
--install-cert -d $DOMAIN \
|
|
--key-file ./server/cert/$DOMAIN.rsa.key \
|
|
--fullchain-file ./server/cert/$DOMAIN.fullchain.rsa.cer
|
|
|
|
$ACME \
|
|
--install-cert -d $DOMAIN --ecc \
|
|
--key-file ./server/cert/$DOMAIN.ecc.key \
|
|
--fullchain-file ./server/cert/$DOMAIN.fullchain.ecc.cer
|
|
|
|
|
|
# gen js file
|
|
cd ./browser/proxy
|
|
|
|
echo "\
|
|
// THIS FILE WAS GENERATED BY build.sh
|
|
// DO NOT MODIFY
|
|
export const MY_ROOT = '$DOMAIN'
|
|
export const HOST_LIST = [
|
|
$js_arr_items]" > ./src/hostlist.js
|
|
|
|
./release.sh |