Files
rmps/scripts/certs/regen-all.sh

41 lines
782 B
Bash
Executable File

#!/bin/bash
if [ -z "$1" ]; then
printf "Enter CA pass: "
read -rs pass
printf "\n"
else
pass=$1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
cd "$DIR"
printf "${RED}Phase 1${NC} - Generating CA...\n"
out=$(./gen-ca.sh $pass 2>&1)
if [[ $out == *error* ]]; then
printf "%s\n" "$out"
exit 1
fi
printf "${RED}Phase 2${NC} - Generating server cert and key...\n"
cd server
out=$(./gen.sh $pass 2>&1)
if [[ $out == *error* ]]; then
printf "%s\n" "$out"
exit 1
fi
printf "${RED}Phase 3${NC} - Generating client cert and key...\n"
cd ../client
out="$(./gen.sh $pass 2>&1)"
if [[ $out == *error* ]]; then
printf "%s\n" "$out"
exit 1
fi
printf "${GREEN}Done!${NC}\n"
chmod -R +r "$DIR"