Skip to content

Commit

Permalink
Merge pull request #47 from 007revad/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
007revad authored Apr 10, 2024
2 parents 9d9c242 + 649847e commit 31d73bb
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v3.0.46
- DSM 6 to 7.1.1 bug fix where script incorrectly showed package failed to stop error. Issue #44
- DSM 6 to 7.1.1 bug fix for not detecting when package was not installed (for Restore mode).

v3.0.45
- Added backup and restore modes.
- Includes syno_app_mover.conf file to set the backup location.
Expand Down
35 changes: 23 additions & 12 deletions syno_app_mover.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@
# https://docs.docker.com/config/pruning/
#
#
# DSM 6 to 7.1.1 bug fix where script incorrectly showed package failed to stop error. Issue #44
# DSM 6 to 7.1.1 bug fix for not detecting when package was not installed (for Restore mode).
#
#
# DONE Bug fix for not editing /var/packages/Calendar/etc/share_link.json. Issue #39
# DONE Bug fix for not moving @synocalendar if it exists. Issue #39
#
#
# DONE Added skip restore if last restore was less than n minutes ago.
# - Set skip_minutes in syno_app_mover.conf
# DONE Skip exit on error and skip processing app if backup all or restore all selected.
Expand Down Expand Up @@ -130,7 +133,7 @@
# DONE Bug fix when script updates itself and user ran the script from ./scriptname.sh


scriptver="v3.0.45"
scriptver="v3.0.46"
script=Synology_app_mover
repo="007revad/Synology_app_mover"
scriptname=syno_app_mover
Expand Down Expand Up @@ -445,7 +448,7 @@ progstatus(){
package_status(){
# $1 is package name
[ "$trace" == "yes" ] && echo "${FUNCNAME[0]} called from ${FUNCNAME[1]}"
local code
# local code
/usr/syno/bin/synopkg status "${1}" >/dev/null
code="$?"
# DSM 7.2 0 = started, 17 = stopped, 255 = not_installed, 150 = broken
Expand All @@ -467,6 +470,14 @@ package_status(){
fi
}

package_is_running(){
# $1 is package name
[ "$trace" == "yes" ] && echo "${FUNCNAME[0]} called from ${FUNCNAME[1]}"
/usr/syno/bin/synopkg is_onoff "${1}" >/dev/null
code="$?"
return "$code"
}

wait_status(){
# Wait for package to finish stopping or starting
# $1 is package
Expand Down Expand Up @@ -1362,7 +1373,8 @@ check_pkg_installed(){
# $1 is package
# $2 is package name
/usr/syno/bin/synopkg status "${1:?}" >/dev/null
if [[ $? == "255" ]]; then
code="$?"
if [[ $code == "255" ]] || [[ $code == "4" ]]; then
ding
echo -e "${Error}ERROR${Off} ${Cyan}${2}${Off} is not installed!"
echo -e "Install ${Cyan}${2}${Off} then try Restore again"
Expand Down Expand Up @@ -1797,19 +1809,17 @@ done
stop_packages(){
# Check package is running
[ "$trace" == "yes" ] && echo "${FUNCNAME[0]} called from ${FUNCNAME[1]}"
if package_status "$pkg"; then
if package_is_running "$pkg"; then

# Stop package
if package_status "$pkg"; then
package_stop "$pkg" "$pkg_name"
#echo ""
fi
package_stop "$pkg" "$pkg_name"

# Check package stopped
if package_status "$pkg"; then
if package_is_running "$pkg"; then
stop_pkg_fail="yes"
ding
echo -e "Line ${LINENO}: ${Error}ERROR${Off} Failed to stop ${pkg_name}!"
# echo "${pkg_name} status $code"
process_error="yes"
if [[ $all != "yes" ]] || [[ $fix != "yes" ]]; then
exit 1 # Skip exit if mode != all and fix != yes
Expand Down Expand Up @@ -1986,7 +1996,7 @@ start_packages(){
[ "$trace" == "yes" ] && echo "${FUNCNAME[0]} called from ${FUNCNAME[1]}"
# if [[ $skip_start != "yes" ]]; then
# Only start package if not already running
if ! package_status "$pkg"; then
if ! package_is_running "$pkg"; then

if [[ ${mode,,} == "backup" ]]; then
answer="y"
Expand All @@ -2004,9 +2014,10 @@ start_packages(){
#echo ""

# Check package started
if ! package_status "$pkg"; then
if ! package_is_running "$pkg"; then
ding
echo -e "Line ${LINENO}: ${Error}ERROR${Off} Failed to start ${pkg_name}!"
# echo "${pkg_name} status $code"
process_error="yes"
if [[ $all != "yes" ]]; then
exit 1 # Skip exit if mode is All
Expand Down

0 comments on commit 31d73bb

Please sign in to comment.