-
Notifications
You must be signed in to change notification settings - Fork 1
/
grm
executable file
·73 lines (64 loc) · 3.17 KB
/
grm
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
#!/bin/bash
##################################################################################
# Copyright 2022 steadfasterX <steadfasterX |at| gmail - com>
# Copyright 2023 steadfasterX <steadfasterX |at| gmail - com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
##################################################################################
#
# GRM - [G]rapheneOS [R]epo [M]anager
#
##################################################################################
# the vars
VARS="${0%/*}/grm.vars"
source $VARS
[ $? -ne 0 ] && "ERROR: Missing requirement: >$VARS<" && exit 3
# the functions
FUNCS="${0%/*}/grm.func"
source $FUNCS
[ $? -ne 0 ] && "ERROR: Missing requirement: >$FUNCS<" && exit 3
# start logging
[ -f "$LOG" ] && echo "backing up old logfile...." && cp -f $LOG ${LOG}.old
echo -e "$(date '+%F %T'): Starting $TNAME v${VERSION}!\n****************************************************\n" > $LOG
# collect some sys info
F_LOG "OS: $(cat /etc/*-release)"
F_LOG "OS (lsb): $(lsb_release -a)"
F_LOG "yad: $(yad --version)"
F_LOG "systemd summary:\n $(hostnamectl status |grep -v ID)\n"
# init app state
# uses always first one as default:
export DEFAULTCHAN="${CHANNELS/!*}"
export DEFAULTSRC="${APPSRCS/!*}"
echo export APPSTATE=$DEFAULTCHAN APPSRC=$DEFAULTSRC > .dyn.vars
F_LOG "Starting with these defaults: $DEFAULTCHAN - $DEFAULTSRC"
# main func
F_MAIN(){
F_LOG "$FUNCNAME: starting menu"
$FYAD --title="$YTITLE" --scroll --image="$SICONS/grm_big.png" --width=650 --height=350 --scroll --text "\n <b>$TFULLNAME</b>\n\n $TNAME is a tool for managing a GrapheneOS repository\t\t\n\n Choose either <i>stable</i> or <i>beta</i>.\n Any <i>beta</i> app HAS TO exist as a <i>stable</i> one as well.\n Having an app just in <i>beta</i> is <b>not</b> supported (by GrapheneOS).\n If you are unsure what to choose use <i>stable</i>:\n" \
--form --field='\t\t\t\t\t\t\t\t\t\t\t\t State:CB' '^'$CHANNELS \
--form --field='\t\t\t\t\t\t\t\t\t\t\t\t Source:CB' '^'$APPSRCS \
--changed-action="sh -c 'echo -e export APPSTATE=%1 APPSRC=%2> .dyn.vars'" \
--buttons-layout=spread \
--button=" About!$SICONS/about_48x48.png":"bash -c F_ABOUT" \
--button=" Log!$SICONS/log_48x48.png":"$MYPATH/getlog" \
--button=" List/Remove Apps!$SICONS/list_48x48.png!List current repo content or remove an existing app":"bash -c F_LISTAPPS" \
--button=" Add/Update App!$SICONS/upload_48x48.png!Add a new app or update an existing one":"bash -c F_ADDAPP"
}
# check first run
F_INITCHK(){
[ ! -f "$MYPATH/${TNAME}.init" ] && F_INIT && F_LOG "$FUNCNAME init done successfully"
}
F_INITCHK >> ${LOG} 2>&1
# main func
F_MAIN
F_EXIT "main->end" 0 full