diff --git a/README.md b/README.md
index a3d1aca..25b865d 100644
--- a/README.md
+++ b/README.md
@@ -5,13 +5,13 @@
push your site files to ebil.club:
```bash
-ebil push --site robin.ebil.club dist/
+ebil push --user robin dist/
```
pull your site from ebil.club to a local directory:
```bash
-ebil pull --site robin.ebil.club site/
+ebil pull --user robin site/
```
## installation
@@ -38,12 +38,13 @@ nix run git+https://codeberg.org/comfysage/ebil.git --
you can set certain options using environment variables.
-| env | option |
-| ---------------------------------------------- | ------------------------ |
-| `EBIL_SITE="robin.ebil.club"` | `--site robin.ebil.club` |
-| `EBIL_PATH="dist/"` | `--path dist/` |
-| `EBIL_HOST="ebil.club"` | |
-| `EBIL_REMOTE="/var/ebil.club/${name}/${site}"` | |
+| env | option |
+| ----------------------------------------------------- | ---------------------------------------- |
+| `EBIL_USER="robin.ebil.club"` | `--user robin` |
+| `EBIL_PATH="dist/"` | `push --from dist/`
`pull --to dist/` |
+| `EBIL_PATH_REMOTE="root"` | `push --to root`
`pull --from root` |
+| `EBIL_HOST="ebil.club"` | |
+| `EBIL_REMOTE="/var/ebil.club/${user}/${path_remote}"` | |
## note
diff --git a/ebil.sh b/ebil.sh
index 62aa231..0271712 100755
--- a/ebil.sh
+++ b/ebil.sh
@@ -30,20 +30,20 @@ phelp() {
usage:
push | push your site files to ebil.club
- > ebil push --site robin.ebil.club dist/
+ > ebil push --user robin dist/
pull | pull your site from ebil.club to a local directory
- > ebil pull --site robin.ebil.club site/
+ > ebil pull --user robin site/
env:
you can set certain options using environment variables.
- EBIL_SITE="robin.ebil.club" | --site robin.ebil.club
- EBIL_PATH="dist/" | push --from dist/
- pull --to dist/
- EBIL_PATH_REMOTE="root" | push --to root
- pull --from root
+ EBIL_USER="robin" | --user robin
+ EBIL_PATH="dist/" | push --from dist/
+ pull --to dist/
+ EBIL_PATH_REMOTE="root" | push --to root
+ pull --from root
EBIL_HOST="ebil.club"
- EBIL_REMOTE="/var/ebil.club/\${name}/\${site}"
+ EBIL_REMOTE="/var/ebil.club/\${user}/\${path_remote}"
note:
specify options *before* regular arguments.
@@ -56,14 +56,6 @@ sourceenv() {
[[ -f .env ]] && export $(grep -v '^#' .env | xargs -0) || return 0
}
-checksite() {
- local site="$1"
- local pat='^[a-z]+\.ebil\.club$'
-
- [[ -z "$site" ]] && die 'site not specified'
- [[ "$site" =~ $pat ]] || die 'malformed site url' "(expected form '${pat}'):" "$site"
-}
-
checkfrom() {
[[ -d "$1" ]] || die 'from does not exist'
}
@@ -78,32 +70,29 @@ rcopy() {
}
push() {
- local site="$1"
+ local user="$1"
local from="$2"
local to="$3"
local host="$4"
local remote="$5"
- local name
from="$(realpath "$from")"
checkfrom "$from"
- if [[ ! -n "$remote" ]]; then
- checksite "$site"
- name="${site%.ebil.club}"
- msg 'user:' "$name"
- remote="/var/ebil.club/${name}/${site}/${to}"
+ if [[ -z "$remote" ]]; then
+ msg 'user:' "$user"
+ remote="/var/ebil.club/${user}/${to}"
fi
[[ -f "${from}/index.txt" ]] && msg 'custom curl message configured' "(${from}/index.txt)"
[[ -f "${from}/index.html" ]] || warn 'index.html not found' "(${from}/index.html)"
- msg 'pushing to' "${site:-${remote}}" 'from' "$from"
+ msg 'pushing to' "${user}@${host}:${to}" 'from' "$from"
rcopy "$from" "${host}:${remote}" --delete --chmod=D755,F644
}
pull() {
- local site="$1"
+ local user="$1"
local from="$2"
local to="$3"
local host="$4"
@@ -116,51 +105,51 @@ pull() {
mkdir -p "$to"
fi
- if [[ ! -n "$(find "$to" -maxdepth 0 -empty)" ]]; then
+ if [[ -z "$(find "$to" -maxdepth 0 -empty)" ]]; then
warn 'destination directory is not empty' "(${to})"
confirm 'are you sure you want to use this directory?'
fi
- if [[ ! -n "$remote" ]]; then
- checksite "$site"
- name="${site%.ebil.club}"
- msg 'user:' "$name"
- remote="/var/ebil.club/${name}/${site}/${from}"
+ if [[ -z "$remote" ]]; then
+ msg 'user:' "$user"
+ remote="/var/ebil.club/${user}/${from}"
fi
- msg 'pulling from' "${site:-${remote}}" 'to' "$to"
+ msg 'pulling from' "${user}@${host}:${from}" 'to' "$to"
rcopy "${host}:${remote}" "$to"
}
main() {
sourceenv
- local site="${EBIL_SITE:-}"
+ local user="${EBIL_USER:-}"
local host="${EBIL_HOST:-ebil.club}"
local remote="${EBIL_REMOTE:-}"
+ local path="${EBIL_PATH:-dist}"
+ local path_remote="${EBIL_PATH_REMOTE:-root}"
- local cmd=''
+ local cmd
if [ "$#" -gt 0 ]; then
cmd="${1#-}"
shift
fi
- local from_opt=''
- local to_opt=''
+ local from
+ local to
while [ "$#" -gt 0 ]; do
case "$1" in
- --site)
- site="$2"
+ --user)
+ user="$2"
shift
;;
--from)
- from_opt="$2"
+ from="$2"
shift
;;
--to)
- to_opt="$2"
+ to="$2"
shift
;;
--help)
@@ -171,33 +160,24 @@ main() {
shift
done
- local from
- local to
+ if [[ -z "$user" ]]; then
+ die 'no user specified'
+ fi
case "$cmd" in
push)
- from="${EBIL_PATH:-dist}"
- to="${EBIL_PATH_REMOTE:-root}"
+ from="${from:-$path}"
+ from="${1:-$from}"
+ to="${to:-$path_remote}"
- if [[ -n "$from_opt" ]]; then
- from="$from_opt"
- else
- [[ -n "${1:-}" ]] && from="$1"
- fi
-
- push "$site" "$from" "$to" "$host" "$remote"
+ push "$user" "$from" "$to" "$host" "$remote"
;;
pull)
- from="${EBIL_PATH_REMOTE:-root}"
- to="${EBIL_PATH:-dst}"
-
- if [[ -n "$to_opt" ]]; then
- to="$to_opt"
- else
- [[ -n "${1:-}" ]] && to="$1"
- fi
+ from="${from:-$path_remote}"
+ to="${to:-$path}"
+ to="${1:-$to}"
- pull "$site" "$from" "$to" "$host" "$remote"
+ pull "$user" "$from" "$to" "$host" "$remote"
;;
'') phelp ;;
*) die 'command not found' ;;