Skip to content

Commit

Permalink
Refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriiNazarenkoTine committed Sep 18, 2024
1 parent 595e8bc commit fac76e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SPK_NAME = rr-manager
SPK_VERS = 2.0
SPK_REV = 68
SPK_REV = 69
SPK_ICON = src/rr-manager.png

DSM_UI_DIR = ui
Expand Down
23 changes: 8 additions & 15 deletions src/service-setup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
PYTHON_DIR="/var/packages/python311/target/bin"
PACKAGE="rr-manager"
INSTALL_DIR="/usr/local/${PACKAGE}"
# PYTHON_DIR="/usr/local/bin/"
PATH="${SYNOPKG_PKGDEST}/env/bin:${SYNOPKG_PKGDEST}/bin:${SYNOPKG_PKGDEST}/usr/bin:${PYTHON_DIR}:${PATH}"
TMP_DIR="${SYNOPKG_PKGDEST}/../../@tmp"
CFG_FILE="${SYNOPKG_PKGDEST}/ui/config.txt"

service_postinst ()
{
Expand All @@ -14,7 +12,6 @@ service_postinst ()

echo ${separator}
install_python_wheels
# /bin/sqlite3 /usr/syno/etc/esynoscheduler/esynoscheduler.db <${SYNOPKG_PKGDEST}/ui/createsqlitedata.sql

echo ${separator}
echo "Install packages to the app/libs folder"
Expand All @@ -25,36 +22,32 @@ service_postinst ()
echo "Populate config.txt"
sed -i -e "s|@this_is_upload_realpath@|${wizard_download_dir}|g" \
-e "s|@this_is_sharename@|${wizard_download_share}|g" \
"${SYNOPKG_PKGDEST}/ui/config.txt"
"${CFG_FILE}"
fi
exit 0
}

service_preupgrade ()
{
# Save configuration files
rm -fr ${TMP_DIR}/${PACKAGE}
mkdir -p ${TMP_DIR}/${PACKAGE}
rm -fr ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${PACKAGE}
mkdir -p ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${PACKAGE}

# Save package config
mv "${SYNOPKG_PKGDEST}/ui/config.txt" "${TMP_DIR}/${PACKAGE}/config.txt"
exit 0
mv "${CFG_FILE}" "${SYNOPKG_TEMP_UPGRADE_FOLDER}/${PACKAGE}/config.txt"
}

service_postupgrade ()
{
rm -f "${SYNOPKG_PKGDEST}/ui/config.txt"
rm -f "${CFG_FILE}"
# Restore package config
mv "${TMP_DIR}/${PACKAGE}/config.txt" "${SYNOPKG_PKGDEST}/ui/config.txt"
mv "${SYNOPKG_TEMP_UPGRADE_FOLDER}/${PACKAGE}/config.txt" "${CFG_FILE}"
touch /tmp/rr_manager_installed
rm -fr ${TMP_DIR}/${PACKAGE}
exit 0
rm -fr ${SYNOPKG_TEMP_UPGRADE_FOLDER}/${PACKAGE}
}

# Uninstall the package does not remove the tasks from the scheduler due to lack of permissions
service_postuninst ()
{
echo "DELETE FROM task WHERE task_name='RunRrUpdate'" | sqlite3 /usr/syno/etc/esynoscheduler/esynoscheduler.db
echo "DELETE FROM task WHERE task_name='ApplyRRConfig'" | sqlite3 /usr/syno/etc/esynoscheduler/esynoscheduler.db
exit 0
}

0 comments on commit fac76e3

Please sign in to comment.