This repository has been archived by the owner on May 22, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcpigs-tool.sh
executable file
·132 lines (114 loc) · 2.55 KB
/
cpigs-tool.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
SELF=$0
MODULES=()
CPIGS_DIR=`dirname "$0"`
CPIGS_DIR=`realpath ${CPIGS_DIR}`
CPIGS_WORKSPACE=$CPIGS_DIR/../cpigs-tool-workspace
mkdir -p $CPIGS_WORKSPACE
function cpigs_register()
{
local module=$1
MODULES+=($module)
}
function cpigs_error()
{
echo $1
exit -1
}
function cpigs_ask()
{
read -p "$1 [$2]: " answer
answer=${answer:-$2}
echo $answer
}
function cpigs_link()
{
local pos=$1
local title=$2
local script=$3
local icon=$4
# echo "linking $title on pos $pos with script $script and icon $icon"
local scriptFile="${PWD}/$1_$2.sh"
local subPath="${PWD#/home/cpi/apps/Menu}"
local iconFile="/home/cpi/launchergo/skin/default/Menu/GameShell${subPath}/$2.png"
# echo $scriptFile
# echo $subPath
# echo $iconFile
cp "${script}" "${scriptFile}"
cp "${icon}" "${iconFile}"
chmod +x "${scriptFile}"
echo "Restart LauncherGo to see change"
}
for module in $CPIGS_DIR/modules/*.sh; do
source $module
done
function bootstrap()
{
sudo apt install -y librsvg2-bin jq
if ! [[ ":$PATH:" == *":$CPIGS_DIR:"* ]]; then
echo "Adding ${CPIGS_DIR} to PATH in /home/cpi/.profile"
echo "PATH=${CPIGS_DIR}:\$PATH" >> /home/cpi/.profile
fi
}
function help()
{
echo "usage: $0 [options] module ..."
echo "options:"
echo "--bootstrap: install dependencies"
echo "--help: this text"
echo "--list: list all known modules"
}
function list()
{
echo "registered modules"
for module in "${MODULES[@]}"
do
local name="$module"
local text=`$module text`
echo "$name: $text"
done
}
function call()
{
local module=$1
shift 1
echo "calling $module with $@"
$module "$@"
}
# banner
echo \
" __ __ __ __ ___
/ |__)|/ _ (_ __ | _ _ | _
\__| |\\__)__) |(_)(_)|_) v$(git -C ${CPIGS_DIR} rev-parse --short HEAD) $(git -C ${CPIGS_DIR} log -1 --format=\"%at\" | xargs -I{} date -d @{} +%Y/%m/%d-%H:%M:%S)
https://github.com/danie1kr/cpigs-tool
"
# setup
mkdir -p /tmp/cpigs
# run arguments
while [ "$#" -gt 0 ]; do
case "$1" in
--help)
help
exit 0
;;
--list)
list
exit 0
;;
--bootstrap)
bootstrap
exit 0
;;
*)
# check if we run in the correct directory
if ! [[ $PWD/ = /home/cpi/apps/Menu/* ]]; then
echo "Please run inside /home/cpi/apps/Menu"
exit -1
fi
module=$1
shift 1
call $module "$@"
exit 0
;;
esac
done