Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # This script copies the newest CertBot cert to SubSonic
- # Folder definitions
- # Change the text within [] and replace [] with ""
- CertTempFolder=[the cert files get updated here, try /home/user/SubCert]
- BackupFolder=[old files live here, try /home/user/SubCert/Backup]
- LELFolder=[Lets Encrypt Live Cert Folder for the domain, default: /etc/letsencrypt/live/your.domain.com]
- SJFolder=[SubSonic JAR folder, default: /usr/share/subsonic]
- # Create folders if they don't exist
- mkdir $CertTempFolder
- mkdir $BackupFolder
- # check for change
- if [ $LELFolder"/privkey.pem" -nt $BackupFolder"/certOld.pem" ];
- then
- # copyNewCertToBackup
- cp -f $LELFolder"/privkey.pem" $BackupFolder"/certOld.pem"
- # backup
- cp -f $SJfolder"/subsonic-booter-jar-with-dependencies.jar" $BackupFolder"/"
- cp -f $CertTempFolder"/subsonic.crt" $BackupFolder"/"
- cp -f $CertTempFolder"/subsonic.pkcs12" $BackupFolder"/"
- cp -f $CertTempFolder"/subsonic.keystore" $BackupFolder"/"
- # deleteOld
- rm $CertTempFolder"/subsonic.crt"
- rm $CertTempFolder"/subsonic.pkcs12"
- rm $CertTempFolder"/subsonic.keystore"
- # Put certs into one file
- cd $LELfolder
- cat privkey.pem cert.pem chain.pem > $CertTempFolder"/subsonic.crt"
- # convert
- cd $CertTempFolder
- openssl pkcs12 -in subsonic.crt -export -out subsonic.pkcs12 -password pass:subsonic
- # create java keystore, pass a yes to insert "subsonic" as the password
- yes subsonic | keytool -importkeystore -srckeystore subsonic.pkcs12 -destkeystore subsonic.keystore -srcstoretype PKCS12 -srcalias 1 -destalias subsonic -storepass subsonic
- #import into java zip
- zip $SJFolder"/subsonic-booter-jar-with-dependencies.jar" subsonic.keystore
- #restart subsonic
- service subsonic restart
- else
- touch $BackupFolder"/certOld.pem"
- fi
Add Comment
Please, Sign In to add comment