this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor!: use `user` instead of `name`+`site`

Reviewed-on: https://codeberg.org/comfysage/ebil/pulls/7
Reviewed-by: june <me@koi.rip>
Signed-off-by: june <me@koi.rip>
Co-authored-by: june <me@koi.rip>

authored by

robin
june
and committed by
june
ad0a26dc 238ebedf

+49 -68
+9 -8
README.md
··· 5 5 push your site files to ebil.club: 6 6 7 7 ```bash 8 - ebil push --site robin.ebil.club dist/ 8 + ebil push --user robin dist/ 9 9 ``` 10 10 11 11 pull your site from ebil.club to a local directory: 12 12 13 13 ```bash 14 - ebil pull --site robin.ebil.club site/ 14 + ebil pull --user robin site/ 15 15 ``` 16 16 17 17 ## installation ··· 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"` | | 46 - | `EBIL_REMOTE="/var/ebil.club/${name}/${site}"` | | 41 + | env | option | 42 + | ----------------------------------------------------- | ---------------------------------------- | 43 + | `EBIL_USER="robin.ebil.club"` | `--user robin` | 44 + | `EBIL_PATH="dist/"` | `push --from dist/`<br>`pull --to dist/` | 45 + | `EBIL_PATH_REMOTE="root"` | `push --to root`<br>`pull --from root` | 46 + | `EBIL_HOST="ebil.club"` | | 47 + | `EBIL_REMOTE="/var/ebil.club/${user}/${path_remote}"` | | 47 48 48 49 ## note 49 50
+40 -60
ebil.sh
··· 30 30 31 31 usage: 32 32 push | push your site files to ebil.club 33 - > ebil push --site robin.ebil.club dist/ 33 + > ebil push --user robin dist/ 34 34 pull | pull your site from ebil.club to a local directory 35 - > ebil pull --site robin.ebil.club site/ 35 + > ebil pull --user robin site/ 36 36 37 37 env: 38 38 you can set certain options using environment variables. 39 39 40 - EBIL_SITE="robin.ebil.club" | --site robin.ebil.club 41 - EBIL_PATH="dist/" | push --from dist/ 42 - pull --to dist/ 43 - EBIL_PATH_REMOTE="root" | push --to root 44 - pull --from root 40 + EBIL_USER="robin" | --user robin 41 + EBIL_PATH="dist/" | push --from dist/ 42 + pull --to dist/ 43 + EBIL_PATH_REMOTE="root" | push --to root 44 + pull --from root 45 45 EBIL_HOST="ebil.club" 46 - EBIL_REMOTE="/var/ebil.club/\${name}/\${site}" 46 + EBIL_REMOTE="/var/ebil.club/\${user}/\${path_remote}" 47 47 48 48 note: 49 49 specify options *before* regular arguments. ··· 56 56 [[ -f .env ]] && export $(grep -v '^#' .env | xargs -0) || return 0 57 57 } 58 58 59 - checksite() { 60 - local site="$1" 61 - local pat='^[a-z]+\.ebil\.club$' 62 - 63 - [[ -z "$site" ]] && die 'site not specified' 64 - [[ "$site" =~ $pat ]] || die 'malformed site url' "(expected form '${pat}'):" "$site" 65 - } 66 - 67 59 checkfrom() { 68 60 [[ -d "$1" ]] || die 'from does not exist' 69 61 } ··· 78 70 } 79 71 80 72 push() { 81 - local site="$1" 73 + local user="$1" 82 74 local from="$2" 83 75 local to="$3" 84 76 local host="$4" 85 77 local remote="$5" 86 - local name 87 78 88 79 from="$(realpath "$from")" 89 80 checkfrom "$from" 90 81 91 - if [[ ! -n "$remote" ]]; then 92 - checksite "$site" 93 - name="${site%.ebil.club}" 94 - msg 'user:' "$name" 95 - remote="/var/ebil.club/${name}/${site}/${to}" 82 + if [[ -z "$remote" ]]; then 83 + msg 'user:' "$user" 84 + remote="/var/ebil.club/${user}/${to}" 96 85 fi 97 86 98 87 [[ -f "${from}/index.txt" ]] && msg 'custom curl message configured' "(${from}/index.txt)" 99 88 [[ -f "${from}/index.html" ]] || warn 'index.html not found' "(${from}/index.html)" 100 89 101 - msg 'pushing to' "${site:-${remote}}" 'from' "$from" 90 + msg 'pushing to' "${user}@${host}:${to}" 'from' "$from" 102 91 rcopy "$from" "${host}:${remote}" --delete --chmod=D755,F644 103 92 } 104 93 105 94 pull() { 106 - local site="$1" 95 + local user="$1" 107 96 local from="$2" 108 97 local to="$3" 109 98 local host="$4" ··· 116 105 mkdir -p "$to" 117 106 fi 118 107 119 - if [[ ! -n "$(find "$to" -maxdepth 0 -empty)" ]]; then 108 + if [[ -z "$(find "$to" -maxdepth 0 -empty)" ]]; then 120 109 warn 'destination directory is not empty' "(${to})" 121 110 confirm 'are you sure you want to use this directory?' 122 111 fi 123 112 124 - if [[ ! -n "$remote" ]]; then 125 - checksite "$site" 126 - name="${site%.ebil.club}" 127 - msg 'user:' "$name" 128 - remote="/var/ebil.club/${name}/${site}/${from}" 113 + if [[ -z "$remote" ]]; then 114 + msg 'user:' "$user" 115 + remote="/var/ebil.club/${user}/${from}" 129 116 fi 130 117 131 - msg 'pulling from' "${site:-${remote}}" 'to' "$to" 118 + msg 'pulling from' "${user}@${host}:${from}" 'to' "$to" 132 119 rcopy "${host}:${remote}" "$to" 133 120 } 134 121 135 122 main() { 136 123 sourceenv 137 124 138 - local site="${EBIL_SITE:-}" 125 + local user="${EBIL_USER:-}" 139 126 local host="${EBIL_HOST:-ebil.club}" 140 127 local remote="${EBIL_REMOTE:-}" 128 + local path="${EBIL_PATH:-dist}" 129 + local path_remote="${EBIL_PATH_REMOTE:-root}" 141 130 142 - local cmd='' 131 + local cmd 143 132 144 133 if [ "$#" -gt 0 ]; then 145 134 cmd="${1#-}" 146 135 shift 147 136 fi 148 137 149 - local from_opt='' 150 - local to_opt='' 138 + local from 139 + local to 151 140 152 141 while [ "$#" -gt 0 ]; do 153 142 case "$1" in 154 - --site) 155 - site="$2" 143 + --user) 144 + user="$2" 156 145 shift 157 146 ;; 158 147 --from) 159 - from_opt="$2" 148 + from="$2" 160 149 shift 161 150 ;; 162 151 --to) 163 - to_opt="$2" 152 + to="$2" 164 153 shift 165 154 ;; 166 155 --help) ··· 171 160 shift 172 161 done 173 162 174 - local from 175 - local to 163 + if [[ -z "$user" ]]; then 164 + die 'no user specified' 165 + fi 176 166 177 167 case "$cmd" in 178 168 push) 179 - from="${EBIL_PATH:-dist}" 180 - to="${EBIL_PATH_REMOTE:-root}" 169 + from="${from:-$path}" 170 + from="${1:-$from}" 171 + to="${to:-$path_remote}" 181 172 182 - if [[ -n "$from_opt" ]]; then 183 - from="$from_opt" 184 - else 185 - [[ -n "${1:-}" ]] && from="$1" 186 - fi 187 - 188 - push "$site" "$from" "$to" "$host" "$remote" 173 + push "$user" "$from" "$to" "$host" "$remote" 189 174 ;; 190 175 pull) 191 - from="${EBIL_PATH_REMOTE:-root}" 192 - to="${EBIL_PATH:-dst}" 193 - 194 - if [[ -n "$to_opt" ]]; then 195 - to="$to_opt" 196 - else 197 - [[ -n "${1:-}" ]] && to="$1" 198 - fi 176 + from="${from:-$path_remote}" 177 + to="${to:-$path}" 178 + to="${1:-$to}" 199 179 200 - pull "$site" "$from" "$to" "$host" "$remote" 180 + pull "$user" "$from" "$to" "$host" "$remote" 201 181 ;; 202 182 '') phelp ;; 203 183 *) die 'command not found' ;;