Skip to content

Commit

Permalink
Merge pull request #24 from 007revad/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
007revad authored Feb 19, 2024
2 parents e408fdd + 27d0287 commit ca6300a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
v1.2.4
- Now shows script version.
- Hard coded /usr/syno/bin/ for Synology commands (to prevent $PATH issues).

v1.2.3
- Check if running as root
- Bug fix
Expand Down
35 changes: 26 additions & 9 deletions syno_dsm_reinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,46 @@
# or as root from task scheduler as a user defined script
#------------------------------------------------------------------------------

scriptver="v1.2.4"
script=Synology_DSM_reinstall
repo="007revad/Synology_DSM_reinstall"
scriptname=syno_reinstall_same_dsm_card

# Show script version
#echo -e "$script $scriptver\ngithub.com/$repo\n"
echo -e "$script $scriptver \n"

# Check script is running as root
if [[ $( whoami ) != "root" ]]; then
echo "This script must be run as root or sudo."
exit
fi

# Check script is running on a Synology NAS
if ! /usr/bin/uname -a | grep -i synology >/dev/null; then
echo "This script is NOT running on a Synology NAS!"
echo "Copy the script to a folder on the Synology"
echo "and run it from there."
exit 1
fi


# Maybe we should backup the VERSION file here

# Prevent DSM auto-updating to "Update #" during reinstall
#if grep '"smart_nano_enabled":true' "/usr/syno/etc/update.conf"; then
sed -i "s/\"smart_nano_enabled\":true/\"smart_nano_enabled\":false/g" "/usr/syno/etc/update.conf"
#fi
##if grep '"smart_nano_enabled":true' "/usr/syno/etc/update.conf"; then
# sed -i "s/\"smart_nano_enabled\":true/\"smart_nano_enabled\":false/g" "/usr/syno/etc/update.conf"
##fi


currentbuild=$(synogetkeyvalue /etc.defaults/VERSION buildnumber)
currentbuild=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/VERSION buildnumber)
if [[ -n $currentbuild ]]; then
echo "Current buildnumber is: $currentbuild"
else
echo "Failed to get buildnumber!" && exit 1
fi

currentbase=$(synogetkeyvalue /etc.defaults/VERSION base)
currentbase=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/VERSION base)
if [[ -n $currentbase ]]; then
echo "Current base is: $currentbase"
echo ""
Expand All @@ -55,16 +72,16 @@ if [[ $newbuild != "$newbase" ]]; then
fi


synosetkeyvalue /etc.defaults/VERSION buildnumber "$newbuild"
value=$(synogetkeyvalue /etc.defaults/VERSION buildnumber)
/usr/syno/bin/synosetkeyvalue /etc.defaults/VERSION buildnumber "$newbuild"
value=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/VERSION buildnumber)
if [[ $value == "$newbuild" ]]; then
echo "Changed buildnumber to: $newbuild"
else
echo "Failed to edit buildnumber!" && exit 1
fi

synosetkeyvalue /etc.defaults/VERSION base "$newbase"
value=$(synogetkeyvalue /etc.defaults/VERSION base)
/usr/syno/bin/synosetkeyvalue /etc.defaults/VERSION base "$newbase"
value=$(/usr/syno/bin/synogetkeyvalue /etc.defaults/VERSION base)
if [[ $value == "$newbase" ]]; then
echo "Changed base to: $newbase"
else
Expand Down

0 comments on commit ca6300a

Please sign in to comment.