Merge claude/1
This commit is contained in:
commit
778e6d739d
@ -24,7 +24,7 @@ appGluetunRecreateRouted()
|
||||
fi
|
||||
|
||||
local installed_apps
|
||||
installed_apps=$(sudo sqlite3 "$docker_dir/$db_file" \
|
||||
installed_apps=$(runInstallOp sqlite3 "$docker_dir/$db_file" \
|
||||
"SELECT name FROM apps WHERE status = 1 ORDER BY name;" 2>/dev/null)
|
||||
|
||||
if ! sudo docker ps --format '{{.Names}}' 2>/dev/null | grep -q '^gluetun-service$'; then
|
||||
|
||||
@ -12,7 +12,7 @@ backupAllApps()
|
||||
local app_names=()
|
||||
while IFS= read -r name; do
|
||||
app_names+=("$name")
|
||||
done < <(sudo sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1;")
|
||||
done < <(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1;")
|
||||
|
||||
if [[ ${#app_names[@]} -eq 0 ]]; then
|
||||
isNotice "No installed applications found — nothing to back up"
|
||||
|
||||
@ -17,7 +17,7 @@ backupScheduleEnabledApps()
|
||||
while IFS= read -r name; do
|
||||
[[ -z "$name" ]] && continue
|
||||
app_names+=("$name")
|
||||
done < <(sudo sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1;")
|
||||
done < <(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1;")
|
||||
|
||||
local queued=0
|
||||
for name in "${app_names[@]}"; do
|
||||
|
||||
@ -20,7 +20,7 @@ viewAppCategoryConfigs()
|
||||
local category_info=$(grep -Po '(?<=# Category : ).*' "$app_config_file")
|
||||
if [ "$category_info" == "$category" ]; then
|
||||
# Check if the app_name is installed based on the database query
|
||||
results=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1 AND name = '$app_name';")
|
||||
results=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1 AND name = '$app_name';")
|
||||
if [[ -n "$results" ]]; then
|
||||
local app_description="\e[32m*INSTALLED*\e[0m - $app_name"
|
||||
installed_apps+=("$app_description")
|
||||
|
||||
@ -10,7 +10,7 @@ tagsProcessorAppUrl()
|
||||
|
||||
local traefik_installed=""
|
||||
if [[ -f "$docker_dir/$db_file" ]] && command -v sqlite3 >/dev/null 2>&1; then
|
||||
traefik_installed=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE name = 'traefik' AND status = 1;" 2>/dev/null)
|
||||
traefik_installed=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE name = 'traefik' AND status = 1;" 2>/dev/null)
|
||||
fi
|
||||
|
||||
local app_url=""
|
||||
@ -19,7 +19,7 @@ tagsProcessorAppUrl()
|
||||
else
|
||||
local external_port=""
|
||||
if [[ -f "$docker_dir/$db_file" ]] && command -v sqlite3 >/dev/null 2>&1; then
|
||||
external_port=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT resource_value FROM network_resources WHERE app_name = '$app_name' AND resource_type = 'port' AND service_name LIKE '%webui%' AND status = 'active' ORDER BY service_name LIMIT 1;" 2>/dev/null | cut -d':' -f1)
|
||||
external_port=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT resource_value FROM network_resources WHERE app_name = '$app_name' AND resource_type = 'port' AND service_name LIKE '%webui%' AND status = 'active' ORDER BY service_name LIMIT 1;" 2>/dev/null | cut -d':' -f1)
|
||||
fi
|
||||
local host="${public_ip_v4:-localhost}"
|
||||
if [[ -n "$external_port" ]]; then
|
||||
|
||||
@ -12,7 +12,7 @@ databaseCycleThroughListApps()
|
||||
local app_names=()
|
||||
while IFS= read -r name; do
|
||||
app_names+=("$name")
|
||||
done < <(sudo sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1;")
|
||||
done < <(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1;")
|
||||
|
||||
for name in "${app_names[@]}"; do
|
||||
isQuestion "Do you want to backup $name? (y/n) "
|
||||
|
||||
@ -20,15 +20,15 @@ databaseInstallApp()
|
||||
fi
|
||||
|
||||
# Check if the app exists in the database
|
||||
app_exists=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT COUNT(*) FROM apps WHERE name = '$app_name';")
|
||||
app_exists=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT COUNT(*) FROM apps WHERE name = '$app_name';")
|
||||
|
||||
if [ "$app_exists" -eq 0 ]; then
|
||||
isNotice "App does not exist in the database, setting up now."
|
||||
local result=$(sudo sqlite3 "$docker_dir/$db_file" "INSERT INTO apps (name, status, install_date, install_time) VALUES ('$app_name', '1', '$current_date', '$current_time');")
|
||||
local result=$(runInstallOp sqlite3 "$docker_dir/$db_file" "INSERT INTO apps (name, status, install_date, install_time) VALUES ('$app_name', '1', '$current_date', '$current_time');")
|
||||
checkSuccess "Adding $app_name to the apps database."
|
||||
else
|
||||
isNotice "App already exists in the database, updating now."
|
||||
local result=$(sudo sqlite3 "$docker_dir/$db_file" "UPDATE apps SET status = '1', install_date = '$current_date', install_time = '$current_time', uninstall_date = NULL WHERE name = '$app_name';")
|
||||
local result=$(runInstallOp sqlite3 "$docker_dir/$db_file" "UPDATE apps SET status = '1', install_date = '$current_date', install_time = '$current_time', uninstall_date = NULL WHERE name = '$app_name';")
|
||||
checkSuccess "Updating apps database for $app_name to installed status."
|
||||
fi
|
||||
}
|
||||
|
||||
@ -15,7 +15,7 @@ databaseListInstalledApps()
|
||||
isHeader "Listing installed apps"
|
||||
|
||||
# Get apps and display them
|
||||
local apps=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1;")
|
||||
local apps=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1;")
|
||||
|
||||
if [ -n "$apps" ]; then
|
||||
echo "$apps" | while IFS="|" read -r app_name; do
|
||||
|
||||
@ -19,7 +19,7 @@ databaseUninstallApp()
|
||||
fi
|
||||
|
||||
# Check if the app exists in the database
|
||||
results=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE name = '$app_name'")
|
||||
results=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE name = '$app_name'")
|
||||
|
||||
if [ -z "$results" ]; then
|
||||
# App not found in the database
|
||||
@ -27,7 +27,7 @@ databaseUninstallApp()
|
||||
else
|
||||
# App found in the database, update status to 0 and set uninstall_date
|
||||
isNotice "Uninstalling $app_name..."
|
||||
if ! sudo sqlite3 "$docker_dir/$db_file" "UPDATE apps SET status = 0, uninstall_date = '$current_date', uninstall_time = '$current_time' WHERE name = '$app_name';"; then
|
||||
if ! runInstallOp sqlite3 "$docker_dir/$db_file" "UPDATE apps SET status = 0, uninstall_date = '$current_date', uninstall_time = '$current_time' WHERE name = '$app_name';"; then
|
||||
isError "Failed to update the database for $app_name."
|
||||
fi
|
||||
isSuccessful "$app_name successfully uninstalled."
|
||||
|
||||
@ -9,7 +9,7 @@ checkIfOSUpdateShouldRun()
|
||||
isNotice "Database file not found: $docker_dir/$db_file"
|
||||
else
|
||||
local table_name="sysupdate"
|
||||
local latest_timestamp=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT datetime(date || ' ' || time) FROM \"$table_name\" ORDER BY date DESC, time DESC LIMIT 1;")
|
||||
local latest_timestamp=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT datetime(date || ' ' || time) FROM \"$table_name\" ORDER BY date DESC, time DESC LIMIT 1;")
|
||||
|
||||
if [[ -n "$latest_timestamp" ]]; then
|
||||
local latest_timestamp_unix=$(date -d "$latest_timestamp" +%s)
|
||||
@ -18,10 +18,10 @@ checkIfOSUpdateShouldRun()
|
||||
local threshold=$(($CFG_UPDATER_CHECK * 60))
|
||||
|
||||
if ((time_difference >= threshold)); then
|
||||
sudo sqlite3 "$docker_dir/$db_file" "UPDATE \"$table_name\" SET date='$current_date', time='$current_time' WHERE ROWID=1;"
|
||||
runInstallOp sqlite3 "$docker_dir/$db_file" "UPDATE \"$table_name\" SET date='$current_date', time='$current_time' WHERE ROWID=1;"
|
||||
fi
|
||||
else
|
||||
sudo sqlite3 "$docker_dir/$db_file" "INSERT INTO \"$table_name\" (date, time) VALUES ('$current_date', '$current_time');"
|
||||
runInstallOp sqlite3 "$docker_dir/$db_file" "INSERT INTO \"$table_name\" (date, time) VALUES ('$current_date', '$current_time');"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
@ -4,6 +4,6 @@ databaseBackupInsert()
|
||||
{
|
||||
local app_name="$1"
|
||||
local table_name=backups
|
||||
local result=$(sudo sqlite3 "$docker_dir/$db_file" "INSERT INTO $table_name (name, date, time) VALUES ('$app_name', '$current_date', '$current_time');")
|
||||
local result=$(runInstallOp sqlite3 "$docker_dir/$db_file" "INSERT INTO $table_name (name, date, time) VALUES ('$app_name', '$current_date', '$current_time');")
|
||||
checkSuccess "Adding $app_name to the $table_name table."
|
||||
}
|
||||
|
||||
@ -5,13 +5,13 @@ databaseOptionInsert()
|
||||
local option="$1"
|
||||
local content="$2"
|
||||
local table_name=options
|
||||
local option_in_db=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT COUNT(*) FROM $table_name WHERE option = '$option';")
|
||||
local option_in_db=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT COUNT(*) FROM $table_name WHERE option = '$option';")
|
||||
|
||||
if [ "$option_in_db" -eq 0 ]; then
|
||||
local result=$(sudo sqlite3 "$docker_dir/$db_file" "INSERT INTO $table_name (option, content) VALUES ('$option', '$content');")
|
||||
local result=$(runInstallOp sqlite3 "$docker_dir/$db_file" "INSERT INTO $table_name (option, content) VALUES ('$option', '$content');")
|
||||
checkSuccess "Adding $option to the $table_name table."
|
||||
else
|
||||
local result=$(sudo sqlite3 "$docker_dir/$db_file" "UPDATE $table_name SET option = '$option', content = '$content';")
|
||||
local result=$(runInstallOp sqlite3 "$docker_dir/$db_file" "UPDATE $table_name SET option = '$option', content = '$content';")
|
||||
checkSuccess "$option already added to the $table_name table. Updating content to $content."
|
||||
fi
|
||||
}
|
||||
|
||||
@ -10,9 +10,9 @@ databasePortOpenInsert()
|
||||
# Split the portdata into port and type
|
||||
IFS='/' read -r port type <<< "$portdata"
|
||||
# Check if already exists in the database
|
||||
local existing_portdata=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT port FROM $table_name WHERE name = '$app_name' AND port = '$port' AND type = '$type';")
|
||||
local existing_portdata=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT port FROM $table_name WHERE name = '$app_name' AND port = '$port' AND type = '$type';")
|
||||
if [ -z "$existing_portdata" ]; then
|
||||
local result=$(sudo sqlite3 "$docker_dir/$db_file" "INSERT INTO $table_name (name, port, type) VALUES ('$app_name', '$port', '$type');")
|
||||
local result=$(runInstallOp sqlite3 "$docker_dir/$db_file" "INSERT INTO $table_name (name, port, type) VALUES ('$app_name', '$port', '$type');")
|
||||
checkSuccess "Adding port $port and type $type for $app_name to the $table_name table."
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -8,9 +8,9 @@ databasePortUsedInsert()
|
||||
if [ -f "$docker_dir/$db_file" ] && [ -n "$app_name" ]; then
|
||||
local table_name=ports
|
||||
# Check if already exists in the database
|
||||
local existing_portdata=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT port FROM $table_name WHERE name = '$app_name' AND port = '$port';")
|
||||
local existing_portdata=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT port FROM $table_name WHERE name = '$app_name' AND port = '$port';")
|
||||
if [ -z "$existing_portdata" ]; then
|
||||
local result=$(sudo sqlite3 "$docker_dir/$db_file" "INSERT INTO $table_name (name, port) VALUES ('$app_name', '$port');")
|
||||
local result=$(runInstallOp sqlite3 "$docker_dir/$db_file" "INSERT INTO $table_name (name, port) VALUES ('$app_name', '$port');")
|
||||
checkSuccess "Adding port $port for $app_name to the $table_name table."
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -4,6 +4,6 @@ databaseRestoreInsert()
|
||||
{
|
||||
local app_name="$1"
|
||||
local table_name=restores
|
||||
local result=$(sudo sqlite3 "$docker_dir/$db_file" "INSERT INTO $table_name (name, date, time) VALUES ('$app_name', '$current_date', '$current_time');")
|
||||
local result=$(runInstallOp sqlite3 "$docker_dir/$db_file" "INSERT INTO $table_name (name, date, time) VALUES ('$app_name', '$current_date', '$current_time');")
|
||||
checkSuccess "Adding $app_name to the $table_name table."
|
||||
}
|
||||
|
||||
@ -21,7 +21,7 @@ databaseDisplayTables()
|
||||
fi
|
||||
|
||||
# Get a list of existing tables in the database
|
||||
local tables_list=($(sudo sqlite3 "$docker_dir/$db_file" ".tables"))
|
||||
local tables_list=($(runInstallOp sqlite3 "$docker_dir/$db_file" ".tables"))
|
||||
|
||||
# Sort the tables alphabetically
|
||||
sorted_tables=($(printf "%s\n" "${tables_list[@]}" | sort))
|
||||
@ -48,7 +48,7 @@ databaseDisplayTables()
|
||||
selected_table="${sorted_tables[$((selected_table-1))]}"
|
||||
# Display all data for the selected table with formatted output
|
||||
isHeader "Displaying $selected_table Table Data"
|
||||
sudo sqlite3 -column -header "$docker_dir/$db_file" "SELECT * FROM $selected_table;"
|
||||
runInstallOp sqlite3 -column -header "$docker_dir/$db_file" "SELECT * FROM $selected_table;"
|
||||
echo ""
|
||||
isQuestion "Press Enter to continue..."
|
||||
read -p "" input
|
||||
|
||||
@ -16,7 +16,7 @@ databaseEmptyTable()
|
||||
fi
|
||||
|
||||
# Get a list of existing tables in the database
|
||||
local tables_list=$(sudo sqlite3 "$docker_dir/$db_file" ".tables")
|
||||
local tables_list=$(runInstallOp sqlite3 "$docker_dir/$db_file" ".tables")
|
||||
|
||||
# Check if there are any tables in the database
|
||||
if [ -z "$tables_list" ]; then
|
||||
@ -35,9 +35,9 @@ databaseEmptyTable()
|
||||
echo ""
|
||||
if [[ "$table_name" == "x" ]]; then
|
||||
isNotice "Exiting."
|
||||
elif sudo sqlite3 "$docker_dir/$db_file" ".tables" | grep -q "\b$table_name\b"; then
|
||||
elif runInstallOp sqlite3 "$docker_dir/$db_file" ".tables" | grep -q "\b$table_name\b"; then
|
||||
# Empty the selected table
|
||||
sudo sqlite3 "$docker_dir/$db_file" "DELETE FROM \"$table_name\";"
|
||||
runInstallOp sqlite3 "$docker_dir/$db_file" "DELETE FROM \"$table_name\";"
|
||||
isSuccessful "Table '$table_name' has been emptied."
|
||||
else
|
||||
isNotice "Invalid table name. Please try again."
|
||||
|
||||
@ -24,7 +24,7 @@ dockerCheckAppInstalled()
|
||||
elif [ ! -f "$docker_dir/$db_file" ]; then
|
||||
package_status="not_installed"
|
||||
else
|
||||
results=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1 AND name = '$app_name';" 2>/dev/null)
|
||||
results=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1 AND name = '$app_name';" 2>/dev/null)
|
||||
if [ -n "$results" ]; then
|
||||
package_status="installed"
|
||||
else
|
||||
|
||||
@ -9,11 +9,11 @@ dockerSwitcherSwap()
|
||||
|
||||
# Select preexisting docker_type
|
||||
if [ -f "$docker_dir/$db_file" ]; then
|
||||
local docker_type=$(sudo sqlite3 "$docker_dir/$db_file" 'SELECT content FROM options WHERE option = "docker_type";')
|
||||
local docker_type=$(runInstallOp sqlite3 "$docker_dir/$db_file" 'SELECT content FROM options WHERE option = "docker_type";')
|
||||
# Insert into DB if something doesnt exist
|
||||
if [[ $docker_type == "" ]]; then
|
||||
databaseOptionInsert "docker_type" $CFG_DOCKER_INSTALL_TYPE;
|
||||
local docker_type=$(sudo sqlite3 "$docker_dir/$db_file" 'SELECT content FROM options WHERE option = "docker_type";')
|
||||
local docker_type=$(runInstallOp sqlite3 "$docker_dir/$db_file" 'SELECT content FROM options WHERE option = "docker_type";')
|
||||
fi
|
||||
else
|
||||
:
|
||||
|
||||
@ -19,7 +19,7 @@ gluetunRouteExistingAppsPrompt()
|
||||
fi
|
||||
|
||||
local installed
|
||||
installed=$(sudo sqlite3 "$docker_dir/$db_file" \
|
||||
installed=$(runInstallOp sqlite3 "$docker_dir/$db_file" \
|
||||
"SELECT name FROM apps WHERE status = 1 AND name NOT IN ('gluetun','libreportal','traefik','fail2ban') ORDER BY name;" 2>/dev/null)
|
||||
|
||||
if [[ -z "$installed" ]]; then
|
||||
|
||||
@ -8,7 +8,7 @@ ipFindAvailable()
|
||||
local start_last=2 # Hardcoded sensible default: .2
|
||||
local end_last=254 # Hardcoded sensible default: .254
|
||||
|
||||
local existing_ips=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT resource_value FROM network_resources WHERE resource_type = 'ip' AND status = 'active';" 2>/dev/null)
|
||||
local existing_ips=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT resource_value FROM network_resources WHERE resource_type = 'ip' AND status = 'active';" 2>/dev/null)
|
||||
if [[ $? -ne 0 ]]; then
|
||||
isError "Database query failed while checking existing IPs"
|
||||
available_ip=""
|
||||
|
||||
@ -5,7 +5,7 @@ portLookupExisting()
|
||||
local app_name="$1"
|
||||
local service_name="$2"
|
||||
local row
|
||||
row=$(sudo sqlite3 "$docker_dir/$db_file" \
|
||||
row=$(runInstallOp sqlite3 "$docker_dir/$db_file" \
|
||||
"SELECT resource_value FROM network_resources \
|
||||
WHERE app_name='$app_name' AND resource_type='port' \
|
||||
AND service_name='$service_name' AND status='active' LIMIT 1;" 2>/dev/null)
|
||||
@ -18,7 +18,7 @@ portAllocate()
|
||||
local app_name="$1"
|
||||
|
||||
if [[ ${#port_config_data[@]} -eq 0 ]]; then
|
||||
local existing_services=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT service_name FROM network_resources WHERE app_name='$app_name' AND resource_type='port' AND service_name LIKE '${app_name}_service_%' AND status='active';" 2>/dev/null)
|
||||
local existing_services=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT service_name FROM network_resources WHERE app_name='$app_name' AND resource_type='port' AND service_name LIKE '${app_name}_service_%' AND status='active';" 2>/dev/null)
|
||||
|
||||
local service_num=1
|
||||
if [[ -n "$existing_services" ]]; then
|
||||
|
||||
@ -44,7 +44,7 @@ portFindNextAvailablePort()
|
||||
fi
|
||||
|
||||
# Check if port is available
|
||||
local check_result=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT 1 FROM network_resources WHERE resource_value LIKE '$random_port:%' AND resource_type='port' AND status='active' LIMIT 1" 2>/dev/null)
|
||||
local check_result=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT 1 FROM network_resources WHERE resource_value LIKE '$random_port:%' AND resource_type='port' AND status='active' LIMIT 1" 2>/dev/null)
|
||||
if [[ -z "$check_result" ]]; then
|
||||
available_port="$random_port"
|
||||
fi
|
||||
@ -59,7 +59,7 @@ portFindNextAvailablePort()
|
||||
if portIsReservedHostPort "$port"; then
|
||||
continue
|
||||
fi
|
||||
local check_result=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT 1 FROM network_resources WHERE resource_value LIKE '$port:%' AND resource_type='port' AND status='active' LIMIT 1" 2>/dev/null)
|
||||
local check_result=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT 1 FROM network_resources WHERE resource_value LIKE '$port:%' AND resource_type='port' AND status='active' LIMIT 1" 2>/dev/null)
|
||||
if [[ -z "$check_result" ]]; then
|
||||
available_port="$port"
|
||||
break
|
||||
|
||||
@ -74,7 +74,7 @@ installRecommendedApps()
|
||||
fi
|
||||
|
||||
# SSHdownload
|
||||
local ssh_new_key=$(sudo sqlite3 "$docker_dir/$db_file" 'SELECT content FROM options WHERE option = "ssh_new_key";')
|
||||
local ssh_new_key=$(runInstallOp sqlite3 "$docker_dir/$db_file" 'SELECT content FROM options WHERE option = "ssh_new_key";')
|
||||
if [[ "$sshdownload_status" != "installed" ]]; then
|
||||
if [[ "$ssh_new_key" == "true" ]]; then
|
||||
isHeader "SSH Key Downloader"
|
||||
|
||||
@ -49,7 +49,7 @@ webuiPatchAppConfigJson() {
|
||||
local installed="false"
|
||||
if [[ -f "$docker_dir/$db_file" ]]; then
|
||||
local row
|
||||
row=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT status FROM apps WHERE name = '${app_name//\'/\'\'}';" 2>/dev/null)
|
||||
row=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT status FROM apps WHERE name = '${app_name//\'/\'\'}';" 2>/dev/null)
|
||||
[[ "$row" == "1" ]] && installed="true"
|
||||
fi
|
||||
|
||||
|
||||
@ -10,7 +10,7 @@ webuiGenerateBackupAppStatus()
|
||||
if [[ -f "$docker_dir/$db_file" ]]; then
|
||||
while IFS= read -r a; do
|
||||
[[ -n "$a" ]] && webuiGenerateBackupAppStatus "$a"
|
||||
done < <(sudo sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1;" 2>/dev/null)
|
||||
done < <(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1;" 2>/dev/null)
|
||||
fi
|
||||
return 0
|
||||
fi
|
||||
|
||||
@ -65,7 +65,7 @@ webuiGenerateBackupDashboard()
|
||||
$first || apps_json+=","
|
||||
first=false
|
||||
apps_json+="{\"app\":\"$app\",\"latest_snapshot\":\"$latest_id\",\"latest_time\":\"$latest_time\"}"
|
||||
done < <(sudo sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1;" 2>/dev/null)
|
||||
done < <(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE status = 1;" 2>/dev/null)
|
||||
fi
|
||||
apps_json+="]"
|
||||
|
||||
|
||||
@ -12,18 +12,18 @@ getLibrePortalWebUIUrls()
|
||||
# Check if sqlite3 is available and database exists
|
||||
if command -v sudo sqlite3 &> /dev/null && [ -f "$docker_dir/$db_file" ]; then
|
||||
# Check if LibrePortal app is installed
|
||||
local libreportal_check=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE name = 'libreportal' AND status = 1;" 2>/dev/null)
|
||||
local libreportal_check=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE name = 'libreportal' AND status = 1;" 2>/dev/null)
|
||||
|
||||
if [[ -n "$libreportal_check" ]]; then
|
||||
# Get the main service IP for LibrePortal
|
||||
local docker_service=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT DISTINCT service_name, resource_value FROM network_resources WHERE app_name = 'libreportal' AND resource_type = 'ip' AND status = 'active' ORDER BY service_name LIMIT 1;" 2>/dev/null)
|
||||
local docker_service=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT DISTINCT service_name, resource_value FROM network_resources WHERE app_name = 'libreportal' AND resource_type = 'ip' AND status = 'active' ORDER BY service_name LIMIT 1;" 2>/dev/null)
|
||||
|
||||
if [[ -n "$docker_service" ]]; then
|
||||
local service_name=$(echo "$docker_service" | cut -d'|' -f1)
|
||||
local service_ip=$(echo "$docker_service" | cut -d'|' -f2)
|
||||
|
||||
# Get the webui port mapping for this service
|
||||
local port_mapping=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT service_name, resource_value FROM network_resources WHERE app_name = 'libreportal' AND resource_type = 'port' AND parent_service = '$service_name' AND service_name LIKE '%webui%' AND status = 'active' ORDER BY service_name LIMIT 1;" 2>/dev/null)
|
||||
local port_mapping=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT service_name, resource_value FROM network_resources WHERE app_name = 'libreportal' AND resource_type = 'port' AND parent_service = '$service_name' AND service_name LIKE '%webui%' AND status = 'active' ORDER BY service_name LIMIT 1;" 2>/dev/null)
|
||||
|
||||
if [[ -n "$port_mapping" ]]; then
|
||||
local port_service_name=$(echo "$port_mapping" | cut -d'|' -f1)
|
||||
@ -35,11 +35,11 @@ getLibrePortalWebUIUrls()
|
||||
local access_type=$(echo "$port_data" | cut -d':' -f3)
|
||||
|
||||
# Check if Traefik is installed for domain access
|
||||
local traefik_installed=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE name = 'traefik' AND status = 1;" 2>/dev/null)
|
||||
local traefik_installed=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT name FROM apps WHERE name = 'traefik' AND status = 1;" 2>/dev/null)
|
||||
|
||||
if [[ -n "$traefik_installed" ]]; then
|
||||
# Get domain from general config
|
||||
local domain=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT resource_value FROM options WHERE option = 'domain_LIBREPORTAL_DOMAIN';" 2>/dev/null)
|
||||
local domain=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT resource_value FROM options WHERE option = 'domain_LIBREPORTAL_DOMAIN';" 2>/dev/null)
|
||||
if [[ -n "$domain" ]]; then
|
||||
libreportal_external_url="https://libreportal.$domain"
|
||||
else
|
||||
@ -64,7 +64,7 @@ getLibrePortalWebUIUrls()
|
||||
# Better fallback: try to find any available port for LibrePortal
|
||||
if [[ -z "$libreportal_external_url" ]]; then
|
||||
# Try to get any port mapping for LibrePortal
|
||||
local any_port=$(sudo sqlite3 "$docker_dir/$db_file" "SELECT resource_value FROM network_resources WHERE app_name = 'libreportal' AND resource_type = 'port' AND status = 'active' LIMIT 1;" 2>/dev/null)
|
||||
local any_port=$(runInstallOp sqlite3 "$docker_dir/$db_file" "SELECT resource_value FROM network_resources WHERE app_name = 'libreportal' AND resource_type = 'port' AND status = 'active' LIMIT 1;" 2>/dev/null)
|
||||
|
||||
if [[ -n "$any_port" ]]; then
|
||||
local external_port=$(echo "$any_port" | cut -d':' -f1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user