Readability improvement

This commit is contained in:
Alexandre Aubin 2018-11-18 17:55:51 +01:00
parent b5afd0abc4
commit 662666fb5a

View file

@ -29,41 +29,52 @@ do_init_regen() {
|| touch "${ssl_dir}/index.txt" || touch "${ssl_dir}/index.txt"
openssl_conf="/usr/share/yunohost/templates/ssl/openssl.cnf" openssl_conf="/usr/share/yunohost/templates/ssl/openssl.cnf"
ynh_ca="/etc/yunohost/certs/yunohost.org/ca.pem"
ynh_crt="/etc/yunohost/certs/yunohost.org/crt.pem"
ynh_key="/etc/yunohost/certs/yunohost.org/key.pem"
# create default certificates # create default certificates
if [[ ! -f /etc/yunohost/certs/yunohost.org/ca.pem ]]; then if [[ ! -f "$ynh_ca" ]]; then
echo -e "\n# Creating the CA key (?)\n" >>$LOGFILE echo -e "\n# Creating the CA key (?)\n" >>$LOGFILE
openssl req -x509 -new -config "$openssl_conf" \
-days 3650 -out "${ssl_dir}/ca/cacert.pem" \ openssl req -x509 \
-keyout "${ssl_dir}/ca/cakey.pem" -nodes -batch >>$LOGFILE 2>&1 -new \
cp "${ssl_dir}/ca/cacert.pem" \ -config "$openssl_conf" \
/etc/yunohost/certs/yunohost.org/ca.pem -days 3650 \
ln -sf /etc/yunohost/certs/yunohost.org/ca.pem \ -out "${ssl_dir}/ca/cacert.pem" \
/etc/ssl/certs/ca-yunohost_crt.pem -keyout "${ssl_dir}/ca/cakey.pem" \
-nodes -batch >>$LOGFILE 2>&1
cp "${ssl_dir}/ca/cacert.pem" "$ynh_ca"
ln -sf "$ynh_ca" /etc/ssl/certs/ca-yunohost_crt.pem
update-ca-certificates update-ca-certificates
fi fi
if [[ ! -f /etc/yunohost/certs/yunohost.org/crt.pem ]]; then if [[ ! -f "$ynh_crt" ]]; then
echo -e "\n# Creating initial key and certificate (?)\n" >>$LOGFILE echo -e "\n# Creating initial key and certificate (?)\n" >>$LOGFILE
openssl req -new -config "$openssl_conf" \
-days 730 -out "${ssl_dir}/certs/yunohost_csr.pem" \ openssl req -new \
-keyout "${ssl_dir}/certs/yunohost_key.pem" -nodes -batch >>$LOGFILE 2>&1 -config "$openssl_conf" \
openssl ca -config "$openssl_conf" \ -days 730 \
-days 730 -in "${ssl_dir}/certs/yunohost_csr.pem" \ -out "${ssl_dir}/certs/yunohost_csr.pem" \
-out "${ssl_dir}/certs/yunohost_crt.pem" -batch >>$LOGFILE 2>&1 -keyout "${ssl_dir}/certs/yunohost_key.pem" \
-nodes -batch >>$LOGFILE 2>&1
openssl ca \
-config "$openssl_conf" \
-days 730 \
-in "${ssl_dir}/certs/yunohost_csr.pem" \
-out "${ssl_dir}/certs/yunohost_crt.pem" \
-batch >>$LOGFILE 2>&1
last_cert=$(ls $ssl_dir/newcerts/*.pem | sort -V | tail -n 1) last_cert=$(ls $ssl_dir/newcerts/*.pem | sort -V | tail -n 1)
chmod 640 "${ssl_dir}/certs/yunohost_key.pem" chmod 640 "${ssl_dir}/certs/yunohost_key.pem"
chmod 640 "$last_cert" chmod 640 "$last_cert"
cp "${ssl_dir}/certs/yunohost_key.pem" \ cp "${ssl_dir}/certs/yunohost_key.pem" "$ynh_key"
/etc/yunohost/certs/yunohost.org/key.pem cp "$last_cert" "$ynh_crt"
cp "$last_cert" \ ln -sf "$ynh_crt" /etc/ssl/certs/yunohost_crt.pem
/etc/yunohost/certs/yunohost.org/crt.pem ln -sf "$ynh_key" /etc/ssl/private/yunohost_key.pem
ln -sf /etc/yunohost/certs/yunohost.org/crt.pem \
/etc/ssl/certs/yunohost_crt.pem
ln -sf /etc/yunohost/certs/yunohost.org/key.pem \
/etc/ssl/private/yunohost_key.pem
fi fi
} }