forked from finn/tinyboard
syncthing.sh: store container name as global ST_CONTAINER
This commit is contained in:
16
syncthing.sh
16
syncthing.sh
@@ -14,13 +14,13 @@ header() { echo -e "\n${CYAN}═════════════════
|
||||
|
||||
ST_URL="http://127.0.0.1:8384"
|
||||
APIKEY=""
|
||||
ST_CONTAINER=""
|
||||
|
||||
get_apikey() {
|
||||
local container
|
||||
container=$(docker ps --format '{{.Names}}' | grep -i syncthing | head -1 || true)
|
||||
[ -n "$container" ] || die "No running Syncthing container found."
|
||||
APIKEY=$(docker exec "$container" cat /var/syncthing/config/config.xml 2>/dev/null | grep -oP '(?<=<apikey>)[^<]+' || true)
|
||||
[ -n "$APIKEY" ] || die "Could not read Syncthing API key from container '$container'."
|
||||
ST_CONTAINER=$(docker ps --format '{{.Names}}' | grep -i syncthing | head -1 || true)
|
||||
[ -n "$ST_CONTAINER" ] || die "No running Syncthing container found."
|
||||
APIKEY=$(docker exec "$ST_CONTAINER" cat /var/syncthing/config/config.xml 2>/dev/null | grep -oP '(?<=<apikey>)[^<]+' || true)
|
||||
[ -n "$APIKEY" ] || die "Could not read Syncthing API key from container '$ST_CONTAINER'."
|
||||
}
|
||||
|
||||
st_get() {
|
||||
@@ -222,11 +222,9 @@ else:
|
||||
|
||||
add_folder() {
|
||||
header "Add Folder"
|
||||
local container
|
||||
container=$(docker ps --format '{{.Names}}' | grep -i syncthing | head -1 || true)
|
||||
if [ -n "$container" ]; then
|
||||
if [ -n "$ST_CONTAINER" ]; then
|
||||
echo "Available folders in /var/syncthing/data/:"
|
||||
docker exec "$container" ls /var/syncthing/data/ 2>/dev/null | sed 's/^/ /' || warn "Could not list data directory."
|
||||
docker exec "$ST_CONTAINER" ls /var/syncthing/data/ 2>/dev/null | sed 's/^/ /' || warn "Could not list data directory."
|
||||
echo ""
|
||||
fi
|
||||
read -rp "Folder path on this device (e.g. /var/syncthing/data/books): " FOLDER_PATH
|
||||
|
||||
Reference in New Issue
Block a user