From f54167c3e0af86b29b32e2cd27ab1c4f637e0726 Mon Sep 17 00:00:00 2001 From: Renat Suleymanov Date: Fri, 27 Mar 2026 00:31:15 +0400 Subject: [PATCH 1/3] Fix libsagui dependency handling for manual installs --- build-deb.sh | 10 ++++++++++ debian/DEBIAN/control | 3 ++- debian/DEBIAN/postinst | 10 ++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/build-deb.sh b/build-deb.sh index 6bad75b..c92390e 100755 --- a/build-deb.sh +++ b/build-deb.sh @@ -83,6 +83,15 @@ validate_binary() { fi } +normalize_maintainer_scripts() { + local script + for script in "${STAGING_DIR}/DEBIAN/postinst" "${STAGING_DIR}/DEBIAN/postrm"; do + if [ -f "${script}" ]; then + sed -i 's/\r$//' "${script}" + fi + done +} + # --------------------------------------------------------------------------- # Main # --------------------------------------------------------------------------- @@ -99,6 +108,7 @@ mkdir -p "${BUILD_DIR}" # Copy staging from sources in /tmp — here chmod works correctly cp -r "${SCRIPT_DIR}/debian" "${STAGING_DIR}" +normalize_maintainer_scripts # Include db_schema.sql — used by postinst to initialize the database mkdir -p "${STAGING_DIR}/usr/share/${PACKAGE_NAME}" diff --git a/debian/DEBIAN/control b/debian/DEBIAN/control index 1a5d7eb..59d328a 100644 --- a/debian/DEBIAN/control +++ b/debian/DEBIAN/control @@ -3,7 +3,8 @@ Priority: optional Maintainer: Renat Suleymanov Architecture: amd64 Section: utils -Depends: dash, libc6 (>= 2.2.5), libsagui2 | libsagui +Depends: dash, libc6 (>= 2.2.5) +Recommends: libsagui2 | libsagui Origin: https://github.com/al-Muhandis/AdminHelper Description: Telegram admin helper Telegram bot service for groups' moderation diff --git a/debian/DEBIAN/postinst b/debian/DEBIAN/postinst index c9ba7dc..91dd213 100644 --- a/debian/DEBIAN/postinst +++ b/debian/DEBIAN/postinst @@ -15,6 +15,10 @@ mysql_available() { command -v mysql &>/dev/null && mysqladmin ping --silent 2>/dev/null } +libsagui_available() { + command -v ldconfig &>/dev/null && ldconfig -p 2>/dev/null | grep -q 'libsagui\.so' +} + # Read current value from JSON (return empty string if null or missing) json_get() { jq -r "$1 // empty" "${CONFIG_FILE}" 2>/dev/null || true @@ -97,6 +101,12 @@ case "$1" in fi done + if ! libsagui_available; then + echo "ERROR: libsagui shared library was not found in dynamic linker cache." >&2 + echo " Install libsagui (package or from source) and run: sudo ldconfig" >&2 + exit 1 + fi + if [ ! -f "${CONFIG_FILE}" ]; then echo "ERROR: config file not found: ${CONFIG_FILE}" >&2 echo " Place tgadmin.json into /etc/tgadmin/ before installing." >&2 From 45da04ca5657f4a9777cfd8685a9a847ef45b941 Mon Sep 17 00:00:00 2001 From: Renat Suleymanov Date: Fri, 27 Mar 2026 01:02:21 +0400 Subject: [PATCH 2/3] Do not fail postinst when mysql root auth is unavailable --- debian/DEBIAN/postinst | 45 +++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/debian/DEBIAN/postinst b/debian/DEBIAN/postinst index 91dd213..51f8efc 100644 --- a/debian/DEBIAN/postinst +++ b/debian/DEBIAN/postinst @@ -121,37 +121,42 @@ case "$1" in # Data base # ---------------------------------------------------------------- if mysql_available; then - # Take password from config if set (package update) - EXISTING_PASS="$(json_get '.AdminHelperDB.Password')" + if mysql -u root -e "SELECT 1" >/dev/null 2>&1; then + # Take password from config if set (package update) + EXISTING_PASS="$(json_get '.AdminHelperDB.Password')" - if [ -z "${EXISTING_PASS}" ]; then - DB_PASS="$(openssl rand -base64 16 | tr -d '/+=' | head -c 20)" - echo "==> Generated new database password." - else - DB_PASS="${EXISTING_PASS}" - echo "==> Using existing database password from config." - fi + if [ -z "${EXISTING_PASS}" ]; then + DB_PASS="$(openssl rand -base64 16 | tr -d '/+=' | head -c 20)" + echo "==> Generated new database password." + else + DB_PASS="${EXISTING_PASS}" + echo "==> Using existing database password from config." + fi - echo "==> Configuring MySQL/MariaDB for ${DB_NAME}..." + echo "==> Configuring MySQL/MariaDB for ${DB_NAME}..." - mysql -u root < Database configured. Credentials saved to ${CONFIG_FILE}" + echo "==> Database configured. Credentials saved to ${CONFIG_FILE}" + else + echo "WARNING: MySQL/MariaDB is running, but root access without password is denied." >&2 + echo " Database bootstrap skipped. Configure DB manually and rerun: sudo dpkg-reconfigure ${PACKAGE_NAME}" >&2 + fi else echo "WARNING: MySQL/MariaDB not found or not running." >&2 echo " Install it, then run: sudo dpkg-reconfigure ${PACKAGE_NAME}" >&2 From 48960de4d91ee2f544b3d665cc3a61aed165adc9 Mon Sep 17 00:00:00 2001 From: Renat Suleymanov Date: Fri, 27 Mar 2026 01:21:53 +0400 Subject: [PATCH 3/3] nope --- build-deb.sh | 2 +- src/adminhelperd.lpi | 51 +++++++++++++++++++------------------------- 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/build-deb.sh b/build-deb.sh index c92390e..d079d42 100755 --- a/build-deb.sh +++ b/build-deb.sh @@ -153,7 +153,7 @@ dpkg-deb --root-owner-group --build "${STAGING_DIR}" "${OUTPUT_DEB}" echo "==> Package built: ${OUTPUT_DEB}" -# Copy ready .deb to needed place +# Copy ready .DEB to needed place mkdir -p "${COPY_TARGET}" cp "${OUTPUT_DEB}" "${COPY_TARGET}/" echo "==> Copied to: ${COPY_TARGET}/${DEB_NAME}" diff --git a/src/adminhelperd.lpi b/src/adminhelperd.lpi index 8bfdc20..bb51c78 100644 --- a/src/adminhelperd.lpi +++ b/src/adminhelperd.lpi @@ -23,7 +23,7 @@ - + @@ -189,7 +189,7 @@ - + @@ -203,13 +203,13 @@ - + - + @@ -217,56 +217,56 @@ - + - + - + - + - + - + - + - + @@ -281,14 +281,14 @@ - + - + @@ -314,7 +314,7 @@ - + @@ -366,39 +366,32 @@ - + - + - - - - - - - - + - - + + - + - +