gmo-pki/install.sh
2026-04-10 15:53:11 +02:00

82 lines
2.1 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
#############################################################
# Script name: install.sh
# Author: Gilles Mouchet (gilles.mouchet@gmail.com
# Version: v1beta 2026-04-05
# Description: This script prepare own pki environment
# License: CC BY-NC 4.0 (https://creativecommons.org/licenses/by-nc/4.0/)
#
# This script is provided "as is", WITHOUT ANY WARRANTY OF ANY KIND.
# Commercial use is strictly prohibited without prior authorization.
#
# Changelog
# [1.0.0] - 2026-04-05
# Project initialization
# - initialization by gilles.mouchet@gmail.com
#
############################################################
#
version=v1beta
cfgPath="/etc/own-pki"
############################################################
# FUNCTIONS
############################################################
#-----------------------------------------------------------
# Display usage
usage() {
cat << EOF
Usage: sudo ./$(basename "$0") options
Template script
Options:
-h, --help - show this help
-v, --version - show script version
Examples:
Show this help
sudo ./$(basename "$0") -h
EOF
}
############################################################
# MAIN
############################################################
# check if the effective user ID is 0 (root)
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root or with sudo."
exit 1
fi
# read cli parameters
while [[ "$#" -gt 0 ]]; do
case "$1" in
version|-v|--version)
cat << EOF
$(basename "$0") $version (c) 1990 - $(date +%Y) by Gilles Mouchet
This script is provided "as is", WITHOUT ANY WARRANTY OF ANY KIND.
Non-Commercial Use License See LICENSE for details
EOF
exit
;;
*|help|-h|--help)
usage
exit
;;
esac
done
if [ ! -d "$cfgPath" ]; then
echo "create $cfgPath"
mkdir $cfgPath
fi
cp own-pki.conf.tmpl $cfgPath/own-pki.conf
echo "*****************************************************"
echo " Installation completed !!"
echo " Adapt the file $cfgPath/own-pki.cfg as you need"
echo "*****************************************************"