Debian Codegraph @

contrib/scripts/astgenkey

raw symbols ◀ ▶ SCIP
1 Debian patch touch this file
1 #!/bin/shscip-shell filesystem . . `/bin/sh`.
2 #
3 # Usage: astgenkey [ -q ] [ -n ] [keyname]
4 #
5 DES3=-des3
6 if [scip-shell system . . `[`. "$1" = "-q" ]; then
7 QUIET='y'
8 if [scip-shell system . . `[`. "$2" = "-n" ]; then
9 DES3=
10 KEY=$3
11 else
12 KEY=$2
13 fi
14 elif [scip-shell system . . `[`. "$1" = "-n" ]; then
15 DES3=
16 if [scip-shell system . . `[`. "$2" = "-q" ]; then
17 QUIET='y'
18 KEY=$3
19 else
20 KEY=$2
21 fi
22 else
23 KEY=$1
24 fi
25
26 if [scip-shell system . . `[`. "$QUIET" != 'y' ]; then
27 echoscip-shell system . . echo. ""
28 echoscip-shell system . . echo. "This script generates an RSA private and public key pair"
29 echoscip-shell system . . echo. "in PEM format for use by Asterisk. You will be asked to"
30 echoscip-shell system . . echo. "enter a passcode for your key multiple times. Please"
31 echoscip-shell system . . echo. "enter the same code each time. The resulting files will"
32 echoscip-shell system . . echo. "need to be moved to /var/lib/asterisk/keys if you want"
33 echoscip-shell system . . echo. "to use them, and any private keys (.key files) will"
34 echoscip-shell system . . echo. "need to be initialized at runtime either by running"
35 echoscip-shell system . . echo. "Asterisk with the '-i' option, or with the 'keys init'"
36 echoscip-shell system . . echo. "command once Asterisk is running."
37 echoscip-shell system . . echo. ""
38 echoscip-shell system . . echo. "Press ENTER to continue or ^C to cancel."
39 read BLAH
40 fi
41
42 while [scip-shell system . . `[`. "$KEY" = "" ]; do
43 echoscip-shell system . . echo. -n "Enter key name: "
44 read KEY
45 done
46
47 rmscip-shell system . . rm. -f ${KEY}.key ${KEY}.pub
48
49 echoscip-shell system . . echo. "Generating SSL key '$KEY': "
•50 oldumask="`umask`"
51 umask 0077
52 opensslscip-shell system . . openssl. genrsa -out ${KEY}.key ${DES3} 1024
•53 [scip-shell system . . `[`. "$(idscip-shell system . . id. -u)" = 0 ] && chownscip-shell system . . chown. asterisk: ${KEY}.key
54 umask $oldumask
55 opensslscip-shell system . . openssl. rsa -in ${KEY}.key -pubout -out ${KEY}.pub
56
57 if [scip-shell system . . `[`. -f "${KEY}.key" ] && [scip-shell system . . `[`. -f "${KEY}.pub" ]; then
58 if [scip-shell system . . `[`. "$QUIET" != 'y' ]; then
59 echoscip-shell system . . echo. "Key creation successful."
60 echoscip-shell system . . echo. "Public key: ${KEY}.pub"
61 echoscip-shell system . . echo. "Private key: ${KEY}.key"
62 fi
63 else
64 echoscip-shell system . . echo. "Unknown error creating keys."
65 fi