this repo has no description

feat: `$EBIL_REMOTE` option

allow overriding the remote directory

+28 -17
+6 -5
README.md
··· 38 38 39 39 you can set certain options using environment variables. 40 40 41 - | env | option | 42 - | ----------------------------- | ------------------------ | 43 - | `EBIL_SITE="robin.ebil.club"` | `--site robin.ebil.club` | 44 - | `EBIL_PATH="dist/"` | `--path dist/` | 45 - | `EBIL_HOST="ebil.club"` | | 41 + | env | option | 42 + | ---------------------------------------------- | ------------------------ | 43 + | `EBIL_SITE="robin.ebil.club"` | `--site robin.ebil.club` | 44 + | `EBIL_PATH="dist/"` | `--path dist/` | 45 + | `EBIL_HOST="ebil.club"` | | 46 + | `EBIL_REMOTE="/var/ebil.club/${name}/${site}"` | | 46 47 47 48 ## note 48 49
+22 -12
ebil.sh
··· 31 31 EBIL_SITE="robin.ebil.club" | --site robin.ebil.club 32 32 EBIL_PATH="dist/" | --path dist/ 33 33 EBIL_HOST="ebil.club" 34 + EBIL_REMOTE="/var/ebil.club/\${name}/\${site}" 34 35 35 36 note: 36 37 specify options *before* regular arguments. ··· 68 69 local site="$1" 69 70 local path="$2" 70 71 local host="$3" 72 + local remote="$4" 71 73 local name 72 74 73 - checksite "$site" 74 75 checkpath "$path" 75 76 76 - name="${site%.ebil.club}" 77 + if [[ ! -n "$remote" ]]; then 78 + checksite "$site" 79 + name="${site%.ebil.club}" 80 + msg 'user:' "$name" 81 + remote="/var/ebil.club/${name}/${site}" 82 + fi 77 83 78 - msg 'user:' "$name" 79 84 [[ -f "${path}/index.txt" ]] && msg 'custom curl message configured' "(${path}/index.txt)" 80 85 [[ -f "${path}/index.html" ]] || warn 'index.html not found' "(${path}/index.html)" 81 86 82 - msg 'pushing to' "$site" 'from' "$path" 83 - rcopy "${path}" "${host}:/var/ebil.club/${name}/${site}" --delete --chmod=D755,F644 87 + msg 'pushing to' "${site:-${remote}}" 'from' "$path" 88 + rcopy "$path" "${host}:${remote}" --delete --chmod=D755,F644 84 89 } 85 90 86 91 pull() { 87 92 local site="$1" 88 93 local path="$2" 89 94 local host="$3" 90 - 91 - checksite "$site" 95 + local remote="$4" 92 96 93 97 if [ ! -d "$path" ]; then 94 98 msg 'creating destination directory' "$path" 95 99 mkdir -p "$path" 96 100 fi 97 101 98 - name="${site%.ebil.club}" 102 + if [[ ! -n "$remote" ]]; then 103 + checksite "$site" 104 + name="${site%.ebil.club}" 105 + msg 'user:' "$name" 106 + remote="/var/ebil.club/${name}/${site}" 107 + fi 99 108 100 - msg 'pulling from' "$site" 'to' "$path" 101 - rcopy "${host}:/var/ebil.club/${name}/${site}" "${path}" 109 + msg 'pulling from' "${site:-${remote}}" 'to' "$path" 110 + rcopy "${host}:${remote}" "$path" 102 111 } 103 112 104 113 main() { ··· 108 117 local site="${EBIL_SITE:-}" 109 118 local path="${EBIL_PATH:-.}" 110 119 local host="${EBIL_HOST:-ebil.club}" 120 + local remote="${EBIL_REMOTE:-}" 111 121 local path_opt='' 112 122 113 123 if [ "$#" -gt 0 ]; then ··· 142 152 path="$(realpath "$path")" 143 153 144 154 case "$cmd" in 145 - push) push "$site" "$path" "$host" ;; 146 - pull) pull "$site" "$path" "$host" ;; 155 + push) push "$site" "$path" "$host" "$remote" ;; 156 + pull) pull "$site" "$path" "$host" "$remote" ;; 147 157 '') phelp ;; 148 158 *) die 'command not found' ;; 149 159 esac