#!/bin/bash
# core/user - User Support
set -e
lib_load 'core/host'
######
# Library Configuration
core_user_config_init() {
lib_setting_vars -ro user_confdir user_datadir user_logdir user_tempdir
lib_setting_vars -ro user_id user_name user_email
user_name=$(id -un)
user_email=$user_name@$domain
}
# $user_confdir - Path to user configuration directory
# Default: ``$HOME/.$package_name``
user_confdir="$HOME/.$package_name"
# $user_datadir - Path to user data directory
# Default: ``$user_confdir/data``
user_datadir="$user_confdir/data"
# $user_logdir - Path to user log directory
# Default: ``$user_confdir/logs``
user_logdir="$user_confdir/logs"
# $user_tempdir - Path to user temporary directory
# Default: ``$tmpdir/$package_name-$USER``
user_tempdir="$tmpdir/$package_name-$USER"
mkdir -p "$user_tempdir"
# $user_id - Numeric user id of the current user.
user_id=$(id -u)
######
# Superuser Support
# is_superuser() - Returns success if the current user is the superuser.
is_superuser() { [[ "$user_id" -eq 0 ]]; }
# require_superuser() - Produces an ``error`` if the current user is
# not the superuser.
require_superuser() {
is_superuser || error "insufficient permission: you must run this tool as root"
}
Generated on Wed Jun 28 07:39:45 PDT 2017 by mcsh d14 v0.20.0.