dtfscripts: Rename to concession

Ha
ha
This commit is contained in:
Salt 2018-09-27 21:02:24 -05:00
parent 15a8a181e2
commit 480c3b5e6d
20 changed files with 48 additions and 48 deletions

View File

@ -24,7 +24,7 @@ function svc_log() {
out=1
col_message="\e[37m"
fi
dtf_log "${col_svcname}${service_name}${col_reset}: ${col_message}${1}${col_reset}" >&${out}
cnc_log "${col_svcname}${service_name}${col_reset}: ${col_message}${1}${col_reset}" >&${out}
}
# Basic pre-start checks. Stick extra checks in prestart-extra

View File

@ -19,6 +19,6 @@ function tsk_log() {
out=1
col_message="\e[37m"
fi
dtf_log "${col_tskname}${task}${col_reset}: ${col_message}${1}${col_reset}" >&${out}
cnc_log "${col_tskname}${task}${col_reset}: ${col_message}${1}${col_reset}" >&${out}
}

View File

@ -24,8 +24,8 @@
# General
unset TERMINAL
# Specific to these dtfscripts
unset DTF_SERVICES
unset DTF_TASKS
unset CNC_SERVICES
unset CNC_TASKS
# Polybar
unset PB_MONITOR
unset PB_WM_RESTACK
@ -42,7 +42,7 @@ unset BSPWM_DESKTOPS_TOTAL
unset BSPWM_DESKTOPS_PRIMARY
unset BSPWM_WINDOW_GAP
function dtf_log() {
function cnc_log() {
name="$(basename $0 .sh)"
if [ -z ${1+x} ]; then return 1; fi
printf "$name: $1\n"
@ -50,97 +50,97 @@ function dtf_log() {
## Patch some directories
if [[ "$PATH" != *"$HOME/.local/bin"* ]]; then
dtf_log "Patching path for $HOME/.local/bin"
cnc_log "Patching path for $HOME/.local/bin"
export PATH="$HOME/.local/bin:$PATH"
fi
if [[ "$XDG_CONFIG_HOME" == "" ]]; then
dtf_log "Correcting configuration directory"
cnc_log "Correcting configuration directory"
export XDG_CONFIG_HOME="$HOME/.config"
fi
if [[ "$XDG_RUNTIME_DIR" == "" ]]; then
dtf_log "Correcting runtime directory"
cnc_log "Correcting runtime directory"
export XDG_RUNTIME_DIR="/run/user/$UID"
fi
## Set some more variables
export DTF_HOME="$HOME/.dtfscripts"
export DTF_DEVICES_DIR="$DTF_HOME/devices"
export DTF_SERVICES_DIR="$DTF_HOME/services"
export DTF_TASKS_DIR="$DTF_HOME/tasks"
export CNC_HOME="$HOME/.concession"
export CNC_DEVICES_DIR="$CNC_HOME/devices"
export CNC_SERVICES_DIR="$CNC_HOME/services"
export CNC_TASKS_DIR="$CNC_HOME/tasks"
## Load device-specific scripts
if [[ -x "$DTF_HOME/devices/$(hostname).rc" ]]; then
dtf_log "Sourcing devices/$(hostname).rc"
source "$DTF_DEVICES_DIR/$(hostname).rc"
if [[ -x "$CNC_DEVICES_DIR/$(hostname).rc" ]]; then
cnc_log "Found device-specific config for $(hostname)"
source "$CNC_DEVICES_DIR/$(hostname).rc"
fi
## Determine which tasks to run
# If DTF_TASKS is set, use that
# If CNC_TASKS is set, use that
# Otherwise, run everything
if [[ "$DTF_TASKS" == "" ]]; then
dtf_log "Performing all tasks"
for task in $DTF_TASKS_DIR/*; do
export DTF_TASKS="$DTF_TASKS $(basename "$task")"
if [[ "$CNC_TASKS" == "" ]]; then
cnc_log "Performing all tasks"
for task in $CNC_TASKS_DIR/*; do
export CNC_TASKS="$CNC_TASKS $(basename "$task")"
done
else
dtf_log "Performing a subset of all tasks"
cnc_log "Performing a subset of all tasks"
fi
## Define (and export) a task run function
function dtf_task_run() {
function cnc_task_run() {
[ -z ${1+x} ] && return 1
task_full="$DTF_TASKS_DIR/$1"
task_full="$CNC_TASKS_DIR/$1"
(
if ! [ -r "$task_full" ]; then
dtf_log "Task is unreadable or missing: $task"
cnc_log "Task is unreadable or missing: $task"
exit 1
fi
if ! [ -x "$task_full" ]; then
dtf_log "Task is unexecutable: $task"
cnc_log "Task is unexecutable: $task"
exit 1
fi
source "$DTF_HOME/common_task.sh"
source "$CNC_HOME/common_task.sh"
source "$task_full"
)
}
export -f dtf_task_run
export -f cnc_task_run
## Run tasks
for task in $DTF_TASKS; do
dtf_task_run $task
for task in $CNC_TASKS; do
cnc_task_run $task
done
## Determine which services to run
# Same as above
if [[ "$DTF_SERVICES" == "" ]]; then
dtf_log "Starting all available services"
for service in $DTF_SERVICES_DIR/*.dtf; do
export DTF_SERVICES="$DTF_SERVICES $(basename "$service")"
if [[ "$CNC_SERVICES" == "" ]]; then
cnc_log "Starting all available services"
for service in $CNC_SERVICES_DIR/*.dtf; do
export CNC_SERVICES="$CNC_SERVICES $(basename "$service")"
done
else
dtf_log "Starting a subset of available services"
cnc_log "Starting a subset of available services"
fi
## Define (and export) service functions
function dtf_service_validate() {
service_full="$DTF_SERVICES_DIR/$1"
function cnc_service_validate() {
service_full="$CNC_SERVICES_DIR/$1"
if ! [ -r "$service_full" ]; then
dtf_log "Service is unreadable or missing: $1"
cnc_log "Service is unreadable or missing: $1"
return 1
fi
if ! [ -x "$service_full" ]; then
dtf_log "Service is unexecutable: $1"
cnc_log "Service is unexecutable: $1"
return 1
fi
return 0
}
export -f dtf_service_validate
export -f cnc_service_validate
function dtf_service_start() {
service_full="$DTF_SERVICES_DIR/$1"
dtf_service_validate $1 || return 1
function cnc_service_start() {
service_full="$CNC_SERVICES_DIR/$1"
cnc_service_validate $1 || return 1
(
source "$DTF_HOME/common_service.sh"
source "$CNC_HOME/common_service.sh"
source "$service_full"
isup && [[ "$service_kill_on_reload" == "true" ]] && stop
prestart || exit 1
@ -149,12 +149,12 @@ function dtf_service_start() {
start-extra
)
}
export -f dtf_service_start
export -f cnc_service_start
## Run startup scripts
for service in $DTF_SERVICES; do
dtf_service_start $service
for service in $CNC_SERVICES; do
cnc_service_start $service
done
dtf_log "Finished initialization"
cnc_log "Finished initialization"

View File

@ -21,7 +21,7 @@
# SOFTWARE.
# Load session startup script
dtfscript="$HOME/.dtfscripts/dtfscript"
dtfscript="$HOME/.concession/concede"
if [[ -x "$dtfscript" ]]; then
source "$dtfscript"
exit 0