In my experience, it’s easiest to save the script in your admin user’s $HOME
directory. Just enter the cat
command right after logging in through SSH, then you are already in the correct directory. No need to use sudo
for becoming root before saving or executing the script. The relevant commands already have sudo
prepended so all you have to do is enter your admin password when asked during execution.
Here is a new script version, with correct formatting:
SYSTEM_CERT_DIR=/usr/syno/etc/certificate/system/default
SYNCTHING_CONF_DIR=/var/packages/syncthing/var
# Before DSM 7.0, use the following instead:
#SYNCTHING_CONF_DIR=/var/packages/syncthing/target/var
SYNCTHING_USER=sc-syncthing
SYNCTHING_GROUP=syncthing
API_KEY=InsertYourAPIKeyHere
sudo cp -v --preserve=timestamps ${SYSTEM_CERT_DIR}/cert.pem ${SYNCTHING_CONF_DIR}/https-cert.pem
sudo cp -v --preserve=timestamps ${SYSTEM_CERT_DIR}/privkey.pem ${SYNCTHING_CONF_DIR}/https-key.pem
sudo chmod 664 ${SYNCTHING_CONF_DIR}/https-cert.pem
sudo chmod 600 ${SYNCTHING_CONF_DIR}/https-key.pem
sudo chown ${SYNCTHING_USER}:${SYNCTHING_GROUP} ${SYNCTHING_CONF_DIR}/https-cert.pem
sudo chown ${SYNCTHING_USER}:${SYNCTHING_GROUP} ${SYNCTHING_CONF_DIR}/https-key.pem
sudo ls -l ${SYNCTHING_CONF_DIR}
curl -k -X POST -H "X-API-Key: ${API_KEY}" https://localhost:8384/rest/system/restart
@halteach could you please try to use code formatting when pasting scripts or commands? Discourse almost certainly breaks the content otherwise, so it won’t work when copy-pasted.