-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-extras.sh
executable file
·69 lines (51 loc) · 1.75 KB
/
install-extras.sh
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
#! /usr/bin/env bash
# shellcheck disable=SC2034
ME="install-extras.sh"
MY_PATH="${BASH_SOURCE[0]}"
MY_FILE="${MY_PATH##*/}"
MY_NAME="${MY_FILE%%.*}"
### archives used herein
MY_INSTALL_UPDATE_TAR_GZ="install-update.tar.gz"
MY_INSTALL_KEEP_TAR_GZ="install-protect.tar.gz"
MY_TITEL="Dolphin User Service Menu Extra Installer"
MY_ICON="uninstall"
### _get_first_user_bin_dir_from_path ( $PATH )
### install-extras.sh might use this to create files or symlinks in variable places
_get_first_user_bin_dir_from_path ()
{
local _path="$1"
local _first=""
_first="$( printf '%s' "$_path" | tr ':' '\n' | grep -e "^${HOME}/" | head -1 )"
if [[ -d "$_first" ]]; then
printf '%s' "$_first"
else
printf '%s' "${DEFAULT_USER_BIN_DIR}"
fi
}
### _check_user_bin_dir <user-bin-dir>
### lookout for user bin/ - create if not existing
_check_user_bin_dir ()
{
local _user_bin_dir="$1"
test -d "$_user_bin_dir" || mkdir "$_user_bin_dir"
test -d "$_user_bin_dir" && return 0 || return 1
}
_check_user_bin_dir_in_path ()
{
local _user_bin_dir="$1"
local _path="${2:-$PATH}"
printf '%s' "${_path}" | tr ':' '\n' | grep -q -e "^${_user_bin_dir}$"
}
_main ()
{
local _user_bin_dir
_user_bin_dir="$(_get_first_user_bin_dir_from_path "$PATH")"
_check_user_bin_dir "$_user_bin_dir" || _error_exit "user bin dir does not exists or could not be created: $_user_bin_dir"
_check_user_bin_dir_in_path "$_user_bin_dir" "$PATH" || _notify "user bin dir is not in your binary search \$PATH: $_user_bin_dir"
### things that could be done here...
### copy just installed files to somewhere or create symlinks to it
### init something
### basicly all the things that can not accomplished through an archive of files
### TODO can symlinks go throug a tar archive? probably yes
}
_main