Skip to content

Commit

Permalink
Merge pull request #142 from 007revad/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
007revad authored Jan 7, 2024
2 parents b0eb8b3 + 183f47c commit 28fdf47
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
v1.1.15
- Now warns if script is located on an NVMe drive.
- Now saves changes.txt as <script-filename>_changes.txt when updating the script.
- To not overwrite changes.txt if my other scripts are in the same folder.
- Minor bug fix.

V1.1.14
- Removed the need for bc by using xargs instead.

Expand Down
24 changes: 17 additions & 7 deletions syno_enable_m2_volume.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# sudo /volume1/scripts/syno_enable_m2_volume.sh
#------------------------------------------------------------------------------

scriptver="v1.1.13"
scriptver="v1.1.15"
script=Synology_enable_M2_volume
repo="007revad/Synology_enable_M2_volume"
scriptname=syno_enable_m2_volume
Expand Down Expand Up @@ -147,7 +147,7 @@ fi
# Check script is running as root
if [[ $( whoami ) != "root" ]]; then
ding
echo -e "${Error}ERROR${Off} This script must be run as root or sudo!"
echo -e "${Error}ERROR${Off} This script must be run as sudo or root!"
exit 1
fi

Expand Down Expand Up @@ -204,6 +204,15 @@ scriptfile=$( basename -- "$source" )
echo "Running from: ${scriptpath}/$scriptfile"


# Warn if script located on M.2 drive
scriptvol=$(echo "$scriptpath" | cut -d"/" -f2)
vg=$(lvdisplay | grep /volume_"${scriptvol#volume}" | cut -d"/" -f3)
md=$(pvdisplay | grep -B 1 -E '[ ]'"$vg" | grep /dev/ | cut -d"/" -f3)
if cat /proc/mdstat | grep "$md" | grep nvme >/dev/null; then
echo -e "${Yellow}WARNING${Off} Don't store this script on an NVMe volume!"
fi


#------------------------------------------------------------------------------
# Check latest release with GitHub API

Expand Down Expand Up @@ -325,7 +334,6 @@ if ! printf "%s\n%s\n" "$tag" "$scriptver" |
"$script-$shorttag.tar.gz!"
syslog_set warn "$script $tag failed to download"
else

if [[ -f /tmp/$script-$shorttag.tar.gz ]]; then
# Extract tar file to /tmp/<script-name>
if ! tar -xf "/tmp/$script-$shorttag.tar.gz" -C "/tmp"; then
Expand All @@ -341,7 +349,7 @@ if ! printf "%s\n%s\n" "$tag" "$scriptver" |
fi

# Copy new script sh file to script location
if ! cp -p "/tmp/$script-$shorttag/$scriptname.sh" "${scriptpath}/${scriptfile}";
if ! cp -p "/tmp/$script-$shorttag/${scriptname}.sh" "${scriptpath}/${scriptfile}";
then
copyerr=1
echo -e "${Error}ERROR${Off} Failed to copy"\
Expand All @@ -352,7 +360,9 @@ if ! printf "%s\n%s\n" "$tag" "$scriptver" |
# Copy new CHANGES.txt file
if [[ $scriptpath =~ /volume* ]]; then
# Copy new CHANGES.txt file to script location
if ! cp -p "/tmp/$script-$shorttag/CHANGES.txt" "$scriptpath"; then
if ! cp -p "/tmp/$script-$shorttag/CHANGES.txt"\
"${scriptpath}/${scriptname}_CHANGES.txt";
then
if [[ $autoupdate != "yes" ]]; then copyerr=1; fi
echo -e "${Error}ERROR${Off} Failed to copy"\
"$script-$shorttag/CHANGES.txt to:\n $scriptpath"
Expand All @@ -372,7 +382,7 @@ if ! printf "%s\n%s\n" "$tag" "$scriptver" |

# Notify of success (if there were no errors)
if [[ $copyerr != 1 ]] && [[ $permerr != 1 ]]; then
echo -e "\n$tag$changestxt downloaded to: ${scriptpath}\n"
echo -e "\n$tag ${scriptfile}$changestxt downloaded to: ${scriptpath}\n"
syslog_set info "$script successfully updated to $tag"

# Reload script
Expand Down Expand Up @@ -692,7 +702,7 @@ fi
# for currently installed NVMe drives
for nvme in /run/synostorage/disks/nvme*; do
if [[ -f "${nvme}/m2_pool_support" ]]; then
echo 1 > "${nvme}/m2_pool_support"
echo -n 1 > "${nvme}/m2_pool_support"
fi
done

Expand Down

0 comments on commit 28fdf47

Please sign in to comment.