Files
matchbox/scripts/setup-data-dir
Dalton Hubble 5cd35d8606 contrib/systemd: Run bootcfg with bootcfg user/group
* Setup data dir with the bootcfg group
2016-05-17 12:30:26 -07:00

39 lines
1009 B
Bash
Executable File

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