#!/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 "*****************************************************"