I need to pass input from my bash script to the commands I run inside the script. I have no idea how to do it. I've searched all day for something like this in bash
.
#!/bin/env bash
# This script is used for generating ssl cert's for websites
# ==========================================================
# Version 1.0
# ==========================================================
# Working dir
# ===========
cd "$(dirname "$0")"
# Debugging
# =========
set -x
# Imput options
# =============
read -p "Domain name: " domain_name;
read -p "Enter password: " pass;
# Verify if there is imput "conditional expressions"
# man test; help [[
# ==================================================
if [[ $domain_name ]]; then
openssl genrsa -aes256 -out root/ca/intermediate/private/${domain_name}.key.pem 2048
chmod 400 root/ca/intermediate/private/${domain_name}.key.pem
openssl req -config root/ca/intermediate/openssl.cnf -key root/ca/intermediate/private/${domain_name}.key.pem -new -sha256 -out root/ca/intermediate/csr/${domain_name}.csr.pem
openssl ca -config root/ca/intermediate/openssl.cnf -extensions server_cert -days 475 -notext -md sha256 -in root/ca/intermediate/csr/${domain_name}.csr.pem -out root/ca/intermediate/certs/${domain_name}.cert.pem
chmod 444 root/ca/intermediate/certs/${domain_name}.cert.pem
else
echo "Insert a domain name."
fi
if openssl x509 -noout -text -in intermediate/certs/${domain_name}.cert.pem; then
openssl verify -CAfile root/ca/intermediate/certs/ca-chain.cert.pem intermediate/certs/${domain_name}.cert.pem
fi
Practically i need the script not fail and automate the creation of ssl
self signed certificates.
The input that i need to pass is: password
, domain name
.