Skip to content

Commit

Permalink
#33, Move mounting loader disk to the scripts level
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriiNazarenkoTine committed Jun 7, 2024
1 parent 34df4d4 commit 219ee3c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
SPK_NAME = rr-manager
SPK_VERS = 2.0
SPK_REV = 42
SPK_REV = 43
SPK_ICON = src/rr-manager.png

DSM_UI_DIR = ui
Expand Down
10 changes: 10 additions & 0 deletions src/conf/privilege_
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,15 @@
"action": "postinst",
"run-as": "package"
}
],
"executable": [
{
"relpath": "ui/getConfig.cgi",
"run-as": "package"
},
{
"relpath": "ui/getAddons.cgi",
"run-as": "package"
}
]
}
2 changes: 0 additions & 2 deletions src/src/appWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,9 @@ export default
},

onOpen: function (a) {
this.apiProvider.runScheduledTask('MountLoaderDisk');
SYNOCOMMUNITY.RRManager.AppWindow.superclass.onOpen.call(this, a);
},
onDestroy: function (e) {
this.apiProvider.runScheduledTask('UnMountLoaderDisk');
SYNOCOMMUNITY.RRManager.AppWindow.superclass.onDestroy.call(this);
}
});
1 change: 0 additions & 1 deletion src/src/tabs/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,6 @@ export default
const self = this;
if (this.loaded) return;
self.appWin.setStatusBusy(null, null, 50);
// self.apiProvider.runScheduledTask('MountLoaderDisk');
(async () => {
const [systemInfo, packages, rrCheckVersion] = await Promise.all([
self.apiProvider.getSytemInfo(),
Expand Down
22 changes: 19 additions & 3 deletions src/ui/getAddons.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import os
import json
import sys
import cgi
import subprocess
from pathlib import Path
path_root = Path(__file__).parents[1]
sys.path.append(str(path_root)+'/libs')
Expand All @@ -25,9 +26,8 @@ def read_user_config():
return "{}"


userConfig = read_user_config()

def read_manifests_in_subdirs(parent_directory):
def read_manifests_in_subdirs(parent_directory,userConfig):
manifests = []

for subdir in next(os.walk(parent_directory))[1]: # Iterates through each subdirectory
Expand Down Expand Up @@ -57,11 +57,27 @@ user = f.read().strip()
ADDONS_PATH = '/mnt/p3/addons/'
response = {}

def callMountLoaderScript(action):
process = subprocess.Popen(['/usr/bin/rr-loaderdisk.sh', action],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)

def mountLoader():
callMountLoaderScript('mountLoaderDisk')

def unmountLoader():
callMountLoaderScript('unmountLoaderDisk')

if len(user) > 0:
addons = read_manifests_in_subdirs(ADDONS_PATH)
# call function to mount the loader by calling the following bash /usr/bin/rr-loaderdisk.sh mountLoaderDisk
mountLoader()
userConfig = read_user_config()
addons = read_manifests_in_subdirs(ADDONS_PATH,userConfig)
response['result'] = addons
response['success'] = True
response['total'] = len(addons)
# call function to unmount the loader by calling the following bash /usr/bin/rr-loaderdisk.sh unmountLoaderDisk
unmountLoader()
else:
response["status"] = "not authenticated"

Expand Down
14 changes: 13 additions & 1 deletion src/ui/getConfig.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import json
import sys
import subprocess

from pathlib import Path
path_root = Path(__file__).parents[1]
Expand Down Expand Up @@ -63,14 +64,24 @@ def read_rr_awaiting_update(fileName):
except e:
return "healthy"


def callMountLoaderScript(action):
process = subprocess.Popen(['/usr/bin/rr-loaderdisk.sh', action],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL)

def mountLoader():
callMountLoaderScript('mountLoaderDisk')

def unmountLoader():
callMountLoaderScript('unmountLoaderDisk')
# Authenticate the user
f = os.popen('/usr/syno/synoman/webman/modules/authenticate.cgi', 'r')
user = f.read().strip()

response = {}

if len(user) > 0:
mountLoader()
response["status"] = "authenticated"
response["user"] = user

Expand All @@ -83,6 +94,7 @@ if len(user) > 0:
response["rr_manager_privilege"] = read_rrmanager_privilege('/var/packages/rr-manager/conf/privilege')
# response["rr_manager_resource"] = read_rrmanager_privilege('/var/packages/rr-manager/conf/resource')
response["rr_health"] = read_rr_awaiting_update(response["rr_manager_config"].get("RR_UPDATE_PROGRESS_FILE"))
unmountLoader()
else:
response["status"] = "not authenticated"

Expand Down

0 comments on commit 219ee3c

Please sign in to comment.