From cf187cbe49312e2030b1720adb79869c21919ce4 Mon Sep 17 00:00:00 2001 From: Recolic Keghart <root@recolic.net> Date: Thu, 12 Dec 2019 01:45:13 -0800 Subject: [PATCH] Add reverse proxy support --- Makefile | 6 +++--- recover.sh | 9 +++++++-- setup.sh | 9 +++++++-- submit.sh | 7 ++++++- 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 80bc763..e7239c4 100644 --- a/Makefile +++ b/Makefile @@ -11,13 +11,13 @@ clean: submit: clean git gc - STUID=$(STUID) STUNAME=$(STUNAME) bash submit.sh + STUID=$(STUID) STUNAME=$(STUNAME) hust_submit_server_host=cernet.cnm.cool bash submit.sh setup: - STUID=$(STUID) STUNAME=$(STUNAME) bash setup.sh + STUID=$(STUID) STUNAME=$(STUNAME) hust_submit_server_host=cernet.cnm.cool bash setup.sh recover: - STUID=$(STUID) STUNAME=$(STUNAME) bash recover.sh + STUID=$(STUID) STUNAME=$(STUNAME) hust_submit_server_host=cernet.cnm.cool bash recover.sh .PHONY: default clean submit diff --git a/recover.sh b/recover.sh index 64f7fb7..75b382f 100644 --- a/recover.sh +++ b/recover.sh @@ -1,3 +1,8 @@ +# Recolic CERNET proxy service: +# dssl.cun.io is not available in public Internet. So you have to use my proxy: cernet.cnm.cool. +# If variable is not set, use original version. +[ "$hust_submit_server_host" = "" ] && hust_submit_server_host=dssl.cun.io + function env_set() { sed -i -e "/^export $2=.*/d" ~/.bashrc echo "export $2=`readlink -e $1`" >> ~/.bashrc @@ -6,10 +11,10 @@ function env_set() { [ -z ${STUID} ] && echo "STUID must be set (RTFM)" && exit [ -z ${STUNAME} ] && echo "STUNAME must be set (RTFM)" && exit echo "uploading public key..." -curl -F "id=${STUID}" -F "name=${STUNAME}" -F "file=@${HOME}/.ssh/id_rsa.pub" https://dssl.cun.io/teach/api/uploads/pasetup +curl -F "id=${STUID}" -F "name=${STUNAME}" -F "file=@${HOME}/.ssh/id_rsa.pub" "https://$hust_submit_server_host/teach/api/uploads/pasetup" sleep 2 echo "recover from remote git..." -git remote add hustpa pa@dssl.cun.io:${STUID}-git +git remote add hustpa "pa@$hust_submit_server_host:${STUID}-git" git fetch hustpa git branch -d pa0 git branch -d pa1 diff --git a/setup.sh b/setup.sh index b264776..110c3eb 100644 --- a/setup.sh +++ b/setup.sh @@ -1,3 +1,8 @@ +# Recolic CERNET proxy service: +# dssl.cun.io is not available in public Internet. So you have to use my proxy: cernet.cnm.cool. +# If variable is not set, use original version. +[ "$hust_submit_server_host" = "" ] && hust_submit_server_host=dssl.cun.io + function env_set() { sed -i -e "/^export $2=.*/d" ~/.bashrc echo "export $2=`readlink -e $1`" >> ~/.bashrc @@ -6,10 +11,10 @@ function env_set() { [ -z ${STUID} ] && echo "STUID must be set (RTFM)" && exit [ -z ${STUNAME} ] && echo "STUNAME must be set (RTFM)" && exit echo "uploading public key..." -curl -F "id=${STUID}" -F "name=${STUNAME}" -F "file=@${HOME}/.ssh/id_rsa.pub" https://dssl.cun.io/teach/api/uploads/pasetup +curl -F "id=${STUID}" -F "name=${STUNAME}" -F "file=@${HOME}/.ssh/RecolicPC.pub" "https://$hust_submit_server_host/teach/api/uploads/pasetup" sleep 2 echo "setup git-remote..." -git remote add hustpa pa@dssl.cun.io:${STUID}-git +git remote add hustpa "pa@$hust_submit_server_host:${STUID}-git" git branch pa0 git branch pa1 git branch pa2 diff --git a/submit.sh b/submit.sh index 84ed945..380b664 100644 --- a/submit.sh +++ b/submit.sh @@ -1,3 +1,8 @@ +# Recolic CERNET proxy service: +# dssl.cun.io is not available in public Internet. So you have to use my proxy: cernet.cnm.cool. +# If variable is not set, use original version. +[ "$hust_submit_server_host" = "" ] && hust_submit_server_host=dssl.cun.io + set -e [ -z ${STUID} ] && echo "STUID must be set (RTFM)" && exit @@ -8,7 +13,7 @@ read task cwd=${PWD##*/} echo "${STUID} (${STUNAME}) submitting ${task}..." -wiki='https://dssl.cun.io/teach/api/uploads/' +wiki="https://$hust_submit_server_host/teach/api/uploads/" tarball=$(mktemp -q).tar.bz2 bash -c "cd .. && tar cj ${cwd} > ${tarball}" -- GitLab