#!/bin/bash -e # USAGE: # ./setup-data-dir [/path/to/data/dir] # Sets up a bootcfg data directory at the given path or assumes the default # data directory path /var/lib/bootcfg. if [ "$EUID" -ne 0 ] then echo "Please run as root" exit fi # default to /var/lib/bootcfg datadir=${1:-"/var/lib/bootcfg"} # Create the directory with the given mode and group # 1 - directory to create if it does not exist # 2 - mode to set the directory to make_bootcfg_directory() { local dir="${1}" local mode="${2}" if [[ -e "${dir}" ]]; then chmod "${mode}" "${dir}" else mkdir --mode="${mode}" "${dir}" fi chgrp bootcfg "${dir}" } # SGID bit so all files created will have the correct group make_bootcfg_directory ${datadir} 2550 make_bootcfg_directory "${datadir}/assets" 2550 make_bootcfg_directory "${datadir}/profiles" 2770 make_bootcfg_directory "${datadir}/groups" 2770 make_bootcfg_directory "${datadir}/ignition" 2770 make_bootcfg_directory "${datadir}/cloud" 2770 make_bootcfg_directory "${datadir}/generic" 2770