View difference between Paste ID: EDfipcbL and 8cSL1uES
SHOW: | | - or go back to the newest paste.
1
#!/bin/sh
2
# This script copies the newest CertBot cert to SubSonic
3
4
# Folder definitions
5
# Change the text within [] and replace [] with ""
6
CertTempFolder=[the cert files get updated here, try /home/user/SubCert]
7
BackupFolder=[old files live here, try /home/user/SubCert/Backup]
8
LELFolder=[Lets Encrypt Live Cert Folder for the domain, default: /etc/letsencrypt/live/your.domain.com]
9
SJFolder=[SubSonic JAR folder, default: /usr/share/subsonic]
10
11
# Create folders if they don't exist
12
mkdir $CertTempFolder
13
mkdir $BackupFolder
14
15
# check for change
16
if [ $LELFolder"/privkey.pem" -nt $BackupFolder"/certOld.pem" ]; 
17
18
then
19
	# copyNewCertToBackup
20
	cp -f $LELFolder"/privkey.pem" $BackupFolder"/certOld.pem"
21
22
	# backup
23
	cp -f $SJfolder"/subsonic-booter-jar-with-dependencies.jar" $BackupFolder"/"
24
	cp -f $CertTempFolder"/subsonic.crt" $BackupFolder"/"
25
	cp -f $CertTempFolder"/subsonic.pkcs12" $BackupFolder"/"
26
	cp -f $CertTempFolder"/subsonic.keystore" $BackupFolder"/"
27
28
	# deleteOld
29
	rm $CertTempFolder"/subsonic.crt"
30
	rm $CertTempFolder"/subsonic.pkcs12"
31
	rm $CertTempFolder"/subsonic.keystore"
32
33
34
	# Put certs into one file
35
	cd $LELfolder
36
	cat privkey.pem cert.pem chain.pem > $CertTempFolder"/subsonic.crt"
37
38
	# convert
39
	cd $CertTempFolder
40
	openssl pkcs12 -in subsonic.crt -export -out subsonic.pkcs12 -password pass:subsonic
41
42
	# create java keystore, pass a yes to insert "subsonic" as the password
43
	yes subsonic | keytool -importkeystore -srckeystore subsonic.pkcs12 -destkeystore subsonic.keystore -srcstoretype PKCS12 -srcalias 1 -destalias subsonic -storepass subsonic
44
45
	#import into java zip
46
	zip $SJFolder"/subsonic-booter-jar-with-dependencies.jar" subsonic.keystore
47
48
	#restart subsonic
49
	service subsonic restart	
50
51
else
52
53
	touch $BackupFolder"/certOld.pem"
54
	
55
fi