blob: f24fbc905b68eb50054f5175216c94253de23334 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
#!/bin/bash
source $AK_LIBDIR/_ak_log
# Wanna talk about it?
_ak_new_line(){
printf '\n'
}
_ak_exit_program(){
# Needs rework:
# cd $curdir
# if [ "$3" == "save_log" ]
# then
# tar cvfz $curdir/$(basename $tempdir)-$launch_timestamp.tgz $tempdir
# fi
# rm -rf $tempdir
if [ $1 -ne 0 ]
then
_ak_log_error "$2 ($1)"
else
_ak_log_exit "$2"
fi
exit $1
}
_ak_help(){
if [ ! -z $fullprogrampath ] && [ -n "$fullprogrampath" ]
then
cat $fullprogrampath |grep '^##'| sed 's/^##//g;s/^ //g' 1>&2
exit 1
else
_ak_log_error "fullprogrampath was not set"
exit 1
fi
}
_ak_title_description(){
if [ ! -n "$descriptionString" ]
then
# Choose to exit with error to enforce standard
_ak_log_error "No description string"
exit 1
# Alternative solution
# full_title="$(printf '%s' "$PROGRAM")"
fi
full_title="$(printf '%s - %s' "$PROGRAM" "$descriptionString")"
delimiter_count=`echo -n $full_title | wc -c`
(
printf '%s' "$full_title"
_ak_new_line
while [ $delimiter_count -gt 0 ]
do
printf '='
delimiter_count=$(($delimiter_count-1))
done
_ak_new_line ) 1>&2
}
_ak_usage(){
_ak_title_description
_ak_help
}
_ak_not_implemented(){
#_ak_title_description
_ak_log_error "Not implemented: $*"
}
_ak_make_temp_directory(){
AK_TEMP="$(mktemp -d /tmp/aktmp-XXXXXXX)"
if [ ! -d "$AK_TEMP" ]
then
_ak_log_error "Could not make $AK_TEMP directory to work in"
exit 1
fi
_ak_log_info "$AK_TEMP created successfully"
echo "$AK_TEMP"
}
_ak_make_temp_file(){
AK_TEMP="$(mktemp /tmp/aktmp-XXXXXXX)"
if [ ! -f "$AK_TEMP" ]
then
_ak_log_error "Could not make $AK_TEMP directory to work in"
exit 1
fi
_ak_log_info "$AK_TEMP created successfully"
echo "$AK_TEMP"
}
|