Start Stop Shell Script Synology NAS

1.9k views Asked by At

I've trouble with a simple start/stop shell script for my Synology DS216play NAS. I want to assamble and mount a USB-Raid volume at boot and unmound + stop it on shutdown. According to synology this should be possible: https://developer.synology.com/developer-guide/integrate_dsm/run_with_system_boot.html

So I wrote this script:

#!/bin/sh
# Mount/Unmount USB raid volume

case “$1” in
    start)
        echo "Mounting USB Raid"
        cp /volume1/.config/mdadm.conf /etc
        mdadm -A /dev/md123
        sleep 1
        mount /dev/md123 /volume1/Media
        ;;
    stop)
        echo "Unmounting USB Raid"  
        umount /dev/md123
        sleep 1
        mdadm --stop /dev/md123
        sleep 1
        rm /etc/madm.conf
        ;;
    *)
        echo "Usage: "$1" {start|stop}"
        exit 1
esac
exit 0

But it allways endup with case *

$ ./mount-usb-raid.sh stop
Usage: stop {start|stop}
1

There are 1 answers

0
melpomene On BEST ANSWER
case “$1” in

That should be

case "$1" in

I.e. use ASCII quotes (") instead of fancy Unicode quotes (, ).

Also, this line is wrong:

        echo "Usage: "$1" {start|stop}"

It should be

        echo "Usage: $1 {start|stop}"

Otherwise $1 will be left unquoted.