Compare commits

...

2 Commits

7 changed files with 380 additions and 15 deletions

View File

@ -11,6 +11,14 @@ A KernelSU module which simplifies the installation of a keybox.xml file by fetc
This client module has been primarially written for KernelSU. I test the module with the latest version of KernelSU-Next. Community testing and support for other root providers is encouraged!
### Testing WebUI Locally
```bash
cd module/webroot # Make sure you are in webroot
bun install # Or NPM
bun start # Start the server
```
## Server
To create a server which is capable of serving the files to a client (user of the module), this will require a server. You can set one up below with minimal effort.
@ -23,7 +31,7 @@ This project prioritizes support for [Bun](https://bun.sh) over NPM. These instr
bun install
```
To run:
### Running the Server
```bash
bun run index.ts
@ -31,7 +39,7 @@ bun run index.ts
### Applying DB Changes
```
```bash
bunx drizzle-kit push
```

View File

@ -1,6 +1,6 @@
ui_print ""
ui_print "=== BEESRV ==="
ui_print "Version: $(grep_prop version $MODPATH/module.prop)"
ui_print "Version: $(grep_prop version $MODPATH/module.prop) ($(grep_prop versionCode $MODPATH/module.prop))"
ui_print "Made with ❤️ by ihatenodejs"
ui_print "==========================="
ui_print ""
@ -37,6 +37,8 @@ mkdir -p /data/adb/beesrv
config_modified=false
if [ ! -f "/data/adb/beesrv/config.txt" ]; then
echo "SERVER=" >> /data/adb/beesrv/config.txt
echo "EMAIL=" >> /data/adb/beesrv/config.txt
echo "DEBUG=false" >> /data/adb/beesrv/config.txt
ui_print "[✔] Config created"
ui_print ""
else
@ -49,6 +51,20 @@ else
config_modified=true
fi
# Check EMAIL var
if ! grep -q "EMAIL=" /data/adb/beesrv/config.txt; then
ui_print "[i] EMAIL variable not found, adding..."
echo "EMAIL=" >> /data/adb/beesrv/config.txt
config_modified=true
fi
# Check DEBUG var
if ! grep -q "DEBUG=" /data/adb/beesrv/config.txt; then
ui_print "[i] DEBUG variable not found, adding..."
echo "DEBUG=false" >> /data/adb/beesrv/config.txt
config_modified=true
fi
if [ "$config_modified" = true ]; then
ui_print "[✔] Config modified successfully"
ui_print ""
@ -58,6 +74,13 @@ else
fi
fi
# Set permissions for scripts
ui_print "[i] Setting permissions for scripts..."
chmod 755 $MODPATH/util/*
sleep 0.5
ui_print "[✔] Permissions set"
ui_print ""
ui_print "== INSTALLATION COMPLETE! =="
ui_print ""
ui_print "Join our Telegram channel: t.me/pontushub"

56
module/util/config.sh Executable file
View File

@ -0,0 +1,56 @@
function show_usage() {
echo "Usage: $0 [-e <email>] [-s <server>]"
echo "Options:"
echo " -e Email address"
echo " -s Server URL"
exit 1
}
function set_email() {
if [[ "$1" == "" ]]; then
echo "[ERROR] Email address is required when using -e"
show_usage
fi
if ! grep -q "EMAIL=" /data/adb/beesrv/config.txt; then
echo "EMAIL=$1" >> /data/adb/beesrv/config.txt
else
sed -i "s/EMAIL=.*/EMAIL=$1/" /data/adb/beesrv/config.txt
fi
echo "Success"
}
function set_server() {
if [[ "$1" == "" ]]; then
echo "[ERROR] Server URL is required when using -s"
show_usage
fi
if ! grep -q "SERVER=" /data/adb/beesrv/config.txt; then
echo "SERVER=$1" >> /data/adb/beesrv/config.txt
else
sed -i "s/SERVER=.*/SERVER=$1/" /data/adb/beesrv/config.txt
fi
echo "Success"
}
while getopts "e:s:" opt; do
case ${opt} in
e )
set_email "$OPTARG"
;;
s )
set_server "$OPTARG"
;;
\? )
echo "[ERROR] Invalid option -$OPTARG"
show_usage
;;
: )
echo "[ERROR] Option -$OPTARG requires an argument"
show_usage
;;
esac
done

View File

@ -2,4 +2,5 @@
dist/
node_modules/
package-lock.json
bun.lock*
bun.lock*
src/css/style.css

View File

@ -1,5 +1,5 @@
{
"name": "parcel-vanilla-starter",
"name": "beesrv-webui",
"private": true,
"version": "0.0.0",
"source": "src/index.html",
@ -9,15 +9,15 @@
"build:css:watch": "bunx @tailwindcss/cli -i ./src/css/style-pre.css -o ./src/css/style.css --watch"
},
"dependencies": {
"@tailwindcss/cli": "^4.1.3",
"@tailwindcss/cli": "^4.1.4",
"kernelsu": "^1.0.6",
"tailwindcss": "^4.1.3"
"tailwindcss": "^4.1.4"
},
"devDependencies": {
"buffer": "^6.0.3",
"events": "^3.3.0",
"os-browserify": "^0.3.0",
"parcel": "^2.14.0",
"parcel": "^2.14.4",
"process": "^0.11.10",
"util": "^0.12.5",
"vm-browserify": "^1.1.2"

View File

@ -65,13 +65,65 @@
</span>
</td>
</tr>
<tr>
<th class="border border-gray-600 p-2 text-left">Debug Mode</th>
<td class="border border-gray-600 p-2">
<span id="debug" class="flex items-center gap-2">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-loader-icon lucide-loader w-5 h-5 animate-spin" id="debugLoader"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>
<span id="debugText">Loading...</span>
</span>
</td>
</tr>
</tbody>
</table>
<h2 class="text-2xl font-bold my-4">Configuration</h2>
<table class="w-full bg-gray-700 border-collapse border border-gray-600">
<tbody>
<tr>
<th class="border border-gray-600 p-2 text-left">Server</th>
<td class="border border-gray-600 p-2">
<span id="server" class="flex items-center gap-2">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-loader-icon lucide-loader w-5 h-5 animate-spin" id="serverLoader"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>
<span id="serverText">Loading...</span>
</span>
<div class="flex items-center justify-between">
<span id="server" class="flex items-center gap-2">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-loader-icon lucide-loader w-5 h-5 animate-spin" id="serverLoader"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>
<span id="serverText">Loading...</span>
</span>
<div class="flex items-center gap-2">
<input type="text" id="serverInput" class="hidden bg-gray-700 border border-gray-600 rounded-md p-1 text-white w-64" placeholder="Enter server URL">
<button id="editServerBtn" class="bg-slate-500 text-white px-3 py-1 rounded-md hover:bg-slate-600 transition-colors">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pencil w-4 h-4"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg>
</button>
<button id="saveServerBtn" class="hidden bg-slate-500 text-white px-3 py-1 rounded-md hover:bg-slate-600 transition-colors">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check w-4 h-4"><path d="M20 6 9 17l-5-5"/></svg>
</button>
<button id="cancelServerBtn" class="hidden bg-gray-600 text-white px-3 py-1 rounded-md hover:bg-gray-700 transition-colors">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x w-4 h-4"><path d="M18 6 6 18"/><path d="M6 6l12 12"/></svg>
</button>
</div>
</div>
</td>
</tr>
<tr>
<th class="border border-gray-600 p-2 text-left">Email</th>
<td class="border border-gray-600 p-2">
<div class="flex items-center justify-between">
<span id="email" class="flex items-center gap-2">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-loader-icon lucide-loader w-5 h-5 animate-spin" id="emailLoader"><path d="M12 2v4"/><path d="m16.2 7.8 2.9-2.9"/><path d="M18 12h4"/><path d="m16.2 16.2 2.9 2.9"/><path d="M12 18v4"/><path d="m4.9 19.1 2.9-2.9"/><path d="M2 12h4"/><path d="m4.9 4.9 2.9 2.9"/></svg>
<span id="emailText">Loading...</span>
</span>
<div class="flex items-center gap-2">
<input type="email" id="emailInput" class="hidden bg-gray-700 border border-gray-600 rounded-md p-1 text-white w-64" placeholder="Enter your email">
<button id="editEmailBtn" class="bg-slate-500 text-white px-3 py-1 rounded-md hover:bg-slate-600 transition-colors">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-pencil w-4 h-4"><path d="M17 3a2.85 2.83 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5Z"/><path d="m15 5 4 4"/></svg>
</button>
<button id="saveEmailBtn" class="hidden bg-slate-500 text-white px-3 py-1 rounded-md hover:bg-slate-600 transition-colors">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-check w-4 h-4"><path d="M20 6 9 17l-5-5"/></svg>
</button>
<button id="cancelEmailBtn" class="hidden bg-gray-600 text-white px-3 py-1 rounded-md hover:bg-gray-700 transition-colors">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-x w-4 h-4"><path d="M18 6 6 18"/><path d="M6 6l12 12"/></svg>
</button>
</div>
</div>
</td>
</tr>
</tbody>
@ -100,5 +152,17 @@
</div>
<p class="mt-4 text-center">Made with ❤️ by ihatenodejs</p>
</main>
<!-- Email Edit Modal -->
<div id="emailModal" class="fixed inset-0 bg-black bg-opacity-50 hidden flex items-center justify-center">
<div class="bg-gray-800 p-6 rounded-lg w-96">
<h3 class="text-xl font-bold mb-4">Edit Email</h3>
<input type="email" id="emailInput" class="w-full bg-gray-700 border border-gray-600 rounded-md p-2 mb-4 text-white" placeholder="Enter your email">
<div class="flex justify-end gap-2">
<button id="cancelEmailBtn" class="bg-gray-600 text-white px-4 py-2 rounded-md hover:bg-gray-700 transition-colors">Cancel</button>
<button id="saveEmailBtn" class="bg-slate-500 text-white px-4 py-2 rounded-md hover:bg-slate-600 transition-colors">Save</button>
</div>
</div>
</div>
</body>
</html>

View File

@ -15,11 +15,51 @@ function hideError() {
errorBox.classList.add("hidden")
}
async function getDebugMode() {
const { errno, stdout } = await exec(`cat ${persist_dir}/config.txt`)
if (errno !== 0) {
showError("Failed to read debug mode")
return false
}
const debug = stdout.split("\n").find(line => line.startsWith("DEBUG="))
if (!debug) {
return false
}
return debug.split("=")[1] === "true"
}
async function getEmail() {
try {
const { errno, stdout, stderr } = await exec(`cat ${persist_dir}/config.txt`)
if (errno !== 0) {
if (await getDebugMode() !== true) {
showError("Failed to read email configuration")
} else {
showError(stderr)
}
return "Unknown"
}
const email = stdout.split("\n").find(line => line.startsWith("EMAIL="))
if (!email) {
return "Not set"
}
return email.split("=")[1]
} catch (error) {
showError("Error reading email configuration")
return "Unknown"
}
}
async function getVersion() {
try {
const { errno, stdout, stderr } = await exec(`cat ${modules_dir}/module.prop`)
if (errno !== 0) {
showError("Failed to read module version")
if (await getDebugMode() !== true) {
showError("Failed to read module version")
} else {
showError(stderr)
}
return "Unknown"
}
const version = stdout.split("\n").find(line => line.startsWith("version="))
@ -38,7 +78,11 @@ async function getServer() {
try {
const { errno, stdout, stderr } = await exec(`cat ${persist_dir}/config.txt`)
if (errno !== 0) {
showError("Failed to read server configuration")
if (await getDebugMode() !== true) {
showError("Failed to read server configuration")
} else {
showError(stderr)
}
return "Unknown"
}
const server = stdout.split("\n").find(line => line.startsWith("SERVER="))
@ -72,25 +116,194 @@ async function checkConnection() {
}
}
async function setEmail(email) {
try {
const { errno, stderr } = await exec(`${modules_dir}/util/config.sh -e "${email.replace(/['"]/g, '')}"`)
if (errno !== 0) {
if (await getDebugMode() !== true) {
showError("Failed to update email configuration")
} else {
showError(stderr)
}
return false
}
return true
} catch (error) {
if (await getDebugMode() !== true) {
showError("Error updating email configuration")
} else {
showError(error)
}
return false
}
}
async function setServer(server) {
try {
const { errno, stderr } = await exec(`${modules_dir}/util/config.sh -s "${server.replace(/['"]/g, '')}"`)
if (errno !== 0) {
if (await getDebugMode() !== true) {
showError("Failed to update server configuration")
} else {
showError(stderr)
}
return false
}
return true
} catch (error) {
if (await getDebugMode() !== true) {
showError("Error updating server configuration")
} else {
showError(error)
}
return false
}
}
document.addEventListener("DOMContentLoaded", async () => {
const versionText = document.getElementById("versionText")
const serverText = document.getElementById("serverText")
const emailText = document.getElementById("emailText")
const debugText = document.getElementById("debugText")
const versionLoader = document.getElementById("versionLoader")
const serverLoader = document.getElementById("serverLoader")
const emailLoader = document.getElementById("emailLoader")
const debugLoader = document.getElementById("debugLoader")
const emailInput = document.getElementById("emailInput")
const serverInput = document.getElementById("serverInput")
const editEmailBtn = document.getElementById("editEmailBtn")
const editServerBtn = document.getElementById("editServerBtn")
const saveEmailBtn = document.getElementById("saveEmailBtn")
const saveServerBtn = document.getElementById("saveServerBtn")
const cancelEmailBtn = document.getElementById("cancelEmailBtn")
const cancelServerBtn = document.getElementById("cancelServerBtn")
// Server editing
function startServerEditing() {
serverText.classList.add("hidden")
serverInput.classList.remove("hidden")
editServerBtn.classList.add("hidden")
saveServerBtn.classList.remove("hidden")
cancelServerBtn.classList.remove("hidden")
serverInput.value = serverText.textContent
serverInput.focus()
}
function stopServerEditing() {
serverText.classList.remove("hidden")
serverInput.classList.add("hidden")
editServerBtn.classList.remove("hidden")
saveServerBtn.classList.add("hidden")
cancelServerBtn.classList.add("hidden")
}
editServerBtn.addEventListener("click", startServerEditing)
cancelServerBtn.addEventListener("click", stopServerEditing)
saveServerBtn.addEventListener("click", async () => {
const newServer = serverInput.value.trim()
if (!newServer) {
showError("Server URL cannot be empty")
return
}
serverLoader.classList.remove("hidden")
serverText.textContent = "Saving..."
stopServerEditing()
const success = await setServer(newServer)
if (success) {
serverText.textContent = newServer
} else {
serverText.textContent = "Error"
}
serverLoader.classList.add("hidden")
})
// Handle enter button for server input
serverInput.addEventListener("keydown", (event) => {
if (event.key === "Enter") {
saveServerBtn.click()
} else if (event.key === "Escape") {
cancelServerBtn.click()
}
})
// Email editing
function startEditing() {
emailText.classList.add("hidden")
emailInput.classList.remove("hidden")
editEmailBtn.classList.add("hidden")
saveEmailBtn.classList.remove("hidden")
cancelEmailBtn.classList.remove("hidden")
emailInput.value = emailText.textContent
emailInput.focus()
}
function stopEditing() {
emailText.classList.remove("hidden")
emailInput.classList.add("hidden")
editEmailBtn.classList.remove("hidden")
saveEmailBtn.classList.add("hidden")
cancelEmailBtn.classList.add("hidden")
}
editEmailBtn.addEventListener("click", startEditing)
cancelEmailBtn.addEventListener("click", stopEditing)
saveEmailBtn.addEventListener("click", async () => {
const newEmail = emailInput.value.trim()
if (!newEmail) {
showError("Email cannot be empty")
return
}
emailLoader.classList.remove("hidden")
emailText.textContent = "Saving..."
stopEditing()
const success = await setEmail(newEmail)
if (success) {
emailText.textContent = newEmail
} else {
emailText.textContent = "Error"
}
emailLoader.classList.add("hidden")
})
// Handle enter button for email input
emailInput.addEventListener("keydown", (event) => {
if (event.key === "Enter") {
saveEmailBtn.click()
} else if (event.key === "Escape") {
cancelEmailBtn.click()
}
})
try {
const version = await getVersion()
const server = await getServer()
const email = await getEmail()
const debug = await getDebugMode()
versionLoader.classList.add("hidden")
serverLoader.classList.add("hidden")
emailLoader.classList.add("hidden")
debugLoader.classList.add("hidden")
versionText.textContent = version
serverText.textContent = server
emailText.textContent = email
debugText.textContent = debug ? "Enabled" : "Disabled"
} catch (error) {
versionLoader.classList.add("hidden")
serverLoader.classList.add("hidden")
emailLoader.classList.add("hidden")
debugLoader.classList.add("hidden")
versionText.textContent = "Error"
serverText.textContent = "Error"
emailText.textContent = "Error"
debugText.textContent = "Error"
}
const checkConnectionBtn = document.getElementById("checkConnection")