Skip to content

Commit

Permalink
Move tar command to function
Browse files Browse the repository at this point in the history
  • Loading branch information
mreid-tt committed Nov 8, 2023
1 parent 8b59e5d commit f417f35
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions spk/owncloud/src/service-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ fi
OCROOT="${WEB_DIR}/${SYNOPKG_PKGNAME}"
JQ="/bin/jq"
SED="/bin/sed"
TAR="/bin/tar"
SYNOSVC="/usr/syno/sbin/synoservice"

if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then
Expand Down Expand Up @@ -71,6 +70,17 @@ exec_sql() {
return $?
}

exec_tar() {
TAR="/bin/tar"
COMMAND="${TAR} $*"
if [ ${SYNOPKG_DSM_VERSION_MAJOR} -lt 7 ]; then
/bin/su "$WEB_USER" -s /bin/sh -c "$COMMAND"
else
$COMMAND
fi
return $?
}

setup_owncloud_instance()
{
if [ "${SYNOPKG_PKG_STATUS}" = "INSTALL" ]; then
Expand Down Expand Up @@ -198,7 +208,7 @@ service_postinst ()
# Extract archive to temp folder
TEMPDIR="${SYNOPKG_PKGTMP}/${SYNOPKG_PKGNAME}"
${MKDIR} "${TEMPDIR}"
${TAR} -xzf "${wizard_backup_file}" -C "${TEMPDIR}" 2>&1
exec_tar -xzf "${wizard_backup_file}" -C "${TEMPDIR}" 2>&1

# Restore configuration files and directories
rsync -aX --update -I "${TEMPDIR}/configs/root/.user.ini" "${TEMPDIR}/configs/root/.htaccess" "${OCROOT}/" 2>&1
Expand Down Expand Up @@ -280,7 +290,7 @@ service_preuninst ()
# Create backup archive
archive_name="$(basename "$TEMPDIR").tar.gz"
echo "Creating compressed archive of ownCloud data in file $archive_name"
${TAR} -C "$TEMPDIR" -czf "${SYNOPKG_PKGTMP}/$archive_name" . 2>&1
exec_tar -C "$TEMPDIR" -czf "${SYNOPKG_PKGTMP}/$archive_name" . 2>&1

# Move archive to export directory
${MKDIR} "${wizard_export_path}"
Expand Down

0 comments on commit f417f35

Please sign in to comment.