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"
|
ST_URL="http://127.0.0.1:8384"
|
||||||
APIKEY=""
|
APIKEY=""
|
||||||
|
ST_CONTAINER=""
|
||||||
|
|
||||||
get_apikey() {
|
get_apikey() {
|
||||||
local container
|
ST_CONTAINER=$(docker ps --format '{{.Names}}' | grep -i syncthing | head -1 || true)
|
||||||
container=$(docker ps --format '{{.Names}}' | grep -i syncthing | head -1 || true)
|
[ -n "$ST_CONTAINER" ] || die "No running Syncthing container found."
|
||||||
[ -n "$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)
|
||||||
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 '$ST_CONTAINER'."
|
||||||
[ -n "$APIKEY" ] || die "Could not read Syncthing API key from container '$container'."
|
|
||||||
}
|
}
|
||||||
|
|
||||||
st_get() {
|
st_get() {
|
||||||
@@ -222,11 +222,9 @@ else:
|
|||||||
|
|
||||||
add_folder() {
|
add_folder() {
|
||||||
header "Add Folder"
|
header "Add Folder"
|
||||||
local container
|
if [ -n "$ST_CONTAINER" ]; then
|
||||||
container=$(docker ps --format '{{.Names}}' | grep -i syncthing | head -1 || true)
|
|
||||||
if [ -n "$container" ]; then
|
|
||||||
echo "Available folders in /var/syncthing/data/:"
|
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 ""
|
echo ""
|
||||||
fi
|
fi
|
||||||
read -rp "Folder path on this device (e.g. /var/syncthing/data/books): " FOLDER_PATH
|
read -rp "Folder path on this device (e.g. /var/syncthing/data/books): " FOLDER_PATH
|
||||||
|
|||||||
Reference in New Issue
Block a user