2017-09-09 2 views
0

Ich habe Probleme mit einem einfachen Start/Stopp-Shell-Skript für meine Synology DS216play NAS. Ich möchte ein USB-Raid-Volume beim Booten installieren und unmound + stoppen beim Herunterfahren. Nach synology sollte dies möglich sein: https://developer.synology.com/developer-guide/integrate_dsm/run_with_system_boot.htmlStart Stop Shell Skript Synology NAS

Also schrieb ich dieses Skript:

#!/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 

Aber es durchweg Endup mit Fall *

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

Antwort

0
case “$1” in 

Das sollte

case "$1" in 

I.e. Verwenden Sie ASCII-Anführungszeichen (") anstelle von ausgefallenen Unicode-Anführungszeichen (, ).

Auch diese Zeile ist falsch:

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

Es sollte

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

Ansonsten $1 wird unquoted gelassen werden.