-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Rem01Gaming <Rem01_Gaming@proton.me>
- Loading branch information
1 parent
c740854
commit 5652d16
Showing
25 changed files
with
870 additions
and
295 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/data/data/com.termux/files/usr/bin/origami-sudo bash | ||
# This file is part of Origami Kernel Manager. | ||
# | ||
# Origami Kernel Manager is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Origami Kernel Manager is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Origami Kernel Manager. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
# Copyright (C) 2023-2024 Rem01Gaming | ||
|
||
database_path="/data/origami-kernel/okm.db" | ||
|
||
sql_query() { | ||
echo "$1" | sqlite3 $database_path | ||
} | ||
|
||
if [ ! -f $database_path ]; then | ||
sql_query "CREATE TABLE tb_storecmd (id TEXT PRIMARY KEY, command TEXT NOT NULL, risky BOOLEAN NOT NULL);" | ||
sql_query "CREATE TABLE tb_info (risk_acceptence BOOLEAN NOT NULL, execstoredcmd BOOLEAN NOT NULL, execstoredcmd_risky BOOLEAN NOT NULL);" | ||
sql_query "INSERT INTO tb_info (risk_acceptence, execstoredcmd, execstoredcmd_risky) VALUES (FALSE, FALSE, FALSE);" | ||
sql_query "PRAGMA auto_vacuum = FULL;" | ||
fi | ||
|
||
risk_acceptence() { | ||
sql_query "SELECT risk_acceptence FROM tb_info;" | ||
} | ||
|
||
accept_risk() { | ||
sql_query "UPDATE tb_info SET risk_acceptence = TRUE;" | ||
} | ||
|
||
execstoredcmd_db() { | ||
sql_query "UPDATE tb_info SET execstoredcmd = $1;" | ||
} | ||
|
||
execstoredcmd_risky_db() { | ||
sql_query "UPDATE tb_info SET execstoredcmd_risky = $1;" | ||
} | ||
|
||
# usage: command2db "identifier" "command" "risky (boolean)" | ||
command2db() { | ||
if [ -f /dev/okm-execstoredcmd ]; then | ||
sql_query "INSERT INTO tb_storecmd (id, command, risky) VALUES ('$1', '$2', $3) ON CONFLICT(id) DO UPDATE SET command='$2', risky=$3;" | ||
fi | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/data/data/com.termux/files/usr/bin/origami-sudo bash | ||
# This file is part of Origami Kernel Manager. | ||
# | ||
# Origami Kernel Manager is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Origami Kernel Manager is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Origami Kernel Manager. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
# Copyright (C) 2023-2024 Rem01Gaming | ||
|
||
execstoredcmd_allow_risky="$(sql_query "SELECT execstoredcmd_risky FROM tb_info;")" | ||
|
||
execstoredcmd() { | ||
while IFS='|' read -r command risky; do | ||
if [ "$risky" -eq 1 ] && [ "$execstoredcmd_allow_risky" -eq 1 ]; then | ||
eval "$command" | ||
elif [ "$risky" -eq 0 ]; then | ||
eval "$command" | ||
fi | ||
done < <(sql_query "SELECT command, risky FROM tb_storecmd;") | ||
} | ||
|
||
init_execstoredcmd() { | ||
read -r -p "Apply previous settings? [Y/n]: " input | ||
case $input in | ||
[Yy]*) | ||
echo "Applying settings..." | ||
execstoredcmd | ||
;; | ||
esac | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/data/data/com.termux/files/usr/bin/origami-sudo bash | ||
# This file is part of Origami Kernel Manager. | ||
# | ||
# Origami Kernel Manager is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# Origami Kernel Manager is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with Origami Kernel Manager. If not, see <https://www.gnu.org/licenses/>. | ||
# | ||
# Copyright (C) 2023-2024 Rem01Gaming | ||
|
||
execstoredcmd_switch() { | ||
case $(fzf_select "Enable Disable" "Apply previous settings from last session: ") in | ||
Enable) execstoredcmd_db TRUE ;; | ||
Disable) execstoredcmd_db FALSE ;; | ||
esac | ||
} | ||
|
||
execstoredcmd_risky_switch() { | ||
case $(fzf_select "Enable Disable" "Allow risky execution: ") in | ||
Enable) execstoredcmd_risky_db TRUE ;; | ||
Disable) execstoredcmd_risky_db FALSE ;; | ||
esac | ||
} | ||
|
||
settings_menu() { | ||
while true; do | ||
clear | ||
echo -e "\e[30;48;2;254;228;208;38;2;0;0;0m Origami Kernel Manager ${VERSION}$(yes " " | sed $(($LINE - 30))'q' | tr -d '\n')\033[0m" | ||
echo -e "\e[38;2;254;228;208m" | ||
echo -e " _________ [] Apply previous settings: $(sql_query "SELECT execstoredcmd FROM tb_info;")" | ||
echo -e " / /\\ [] Allow risky execution: $(sql_query "SELECT execstoredcmd_risky FROM tb_info;")" | ||
echo -e " / / \\ " | ||
echo -e " / / \\ " | ||
echo -e "/________/ \\ " | ||
echo -e "\\ \\ / " | ||
echo -e " \\ \\ / " | ||
echo -e " \\ \\ / " | ||
echo -e " \\________\\/ " | ||
echo -e "\n//////////////" | ||
echo -e "$(yes "─" | sed ${LINE}'q' | tr -d '\n')\n" | ||
echo -e "[] OKM Settings\033[0m" | ||
|
||
# Hide cursor | ||
tput civis | ||
|
||
case $(fzy_select "Apply previous settings\nAllow risky execution\nBack to main menu" "") in | ||
"Apply previous settings") execstoredcmd_switch ;; | ||
"Allow risky execution") execstoredcmd_risky_switch ;; | ||
"Back to main menu") break ;; | ||
esac | ||
done | ||
} |
Oops, something went wrong.