#!/bin/sh # ===================================================================== # Projet : DARKCONTAINER # Fichier : lib/nodeService # Auteur : Nicolas "DarkHack" Chapuis (c) 2026 # ================== DARKHACK ================== # [ darkweb.fr - system online ] # Powered by Perplexity, your AI assistant # https://www.perplexity.ai # ============================================== # # 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. # ===================================================================== if ! type "shInclude" > /dev/null 2>&1; then racineSh="${racineSh:-/etc/darksh}"; . "$racineSh/lib/shTools"; shDebugEnable="1";fi rootDarkContainer="${rootDarkContainer:-/etc/darkcontainer}" [ ! -d "$rootDarkContainer" ] && shDebug 0 "exit cause rootDarkContainer is not dir:$rootDarkContainer" >&2 && exit 0 #|-------------------------------------------------------------| #| which "base" tools : cp | rm | echo | head | tail | #|-------------------------------------------------------------| # &&&&& #|-----------------------------------------------------------------------| #| which "directory" tools : mkdir | chmod | chgrp | mount | umount | #|-----------------------------------------------------------------------| # &&&&& #|------------------------------------------------------------------------------------| #| which "user right" tools : chmod | chown | chgrp | groupadd | useradd | chroot | #|------------------------------------------------------------------------------------| $(shInclude $rootDarkContainer/which/lib/base) && $(shInclude $rootDarkContainer/which/lib/systemctl) && $(shInclude $rootDarkContainer/which/lib/userRight) $(shInclude $rootDarkContainer/lib/chroot) && $(shInclude $rootDarkContainer/lib/rsyslog) $(shInclude $rootDarkContainer/lib/services) cmdStartStopDaemon="$(which start-stop-daemon 2>/dev/null )" cmdSh="$(which sh)" # pName="$pName" nodeService_create nodeService_create() { local log="nodeService_create:" shErrorOnMissing "pName" shErrorOnMissing "cmdMkdir" shDebug 1 ""$log" ${pName}" if [ ! -d /etc/node ];then $cmdMkdir /etc/node; elif [ -f /etc/node/$pName ];then /etc/node/$pName stop;fi } #pChrootDir="$pChrootDir" pName="$pName" pUser="$pUser" pGroup="$pGroup"\ #pCacheDir="$pCacheDir" pServiceInfo="$pServiceInfo" cmdDaemon="$cmdDaemon"\ #pLibFiles="$pLibFiles" pLibFolders="$pLibFolders" pCopyLib="$pCopyLib" pDirStruct="$pDirStruct"\ # nodeService_chroot_init nodeService_chroot_init() { local log="nodeService_chroot_init:" shErrorOnMissing "pChrootDir pName pUser pGroup" shErrorOnMissing "pCacheDir pServiceInfo cmdDaemon pLibFiles" shWarnOnMissing "pCopyLib pLibFolders pDirStruct" shDebug 1 ""$log" $pName" racineSh="$racineSh" rootDarkContainer="$rootDarkContainer" sh "$rootDarkContainer/bin/container" force-stop "$( echo $pChrootDir | base64 )" #pChrootDir="$pChrootDir" pName="$pName" pUser="$pUser" pGroup="$pGroup"\ #pCacheDir="$pCacheDir" pServiceInfo="$pServiceInfo"\ # chroot_init chroot_init_install } # pName="" pServiceInfo="" pServiceDoc=""\ # pChrootDir="" pUser="" pGroup="" pMountFolders="" pDirUserGroupRight=""\ # pStart="" pPreStart="" pStop="" pReload="" pIdFile="" serviceType=""\ ## pSystemCtlWants="" pSystemCtlBefore="" pSystemCtlAfter=""\ # pInitVRequiredStart="" pInitVRequiredStop="" pInitVShouldStart="" pInitVShouldStop="" pInitVDefaultStart="" pInitVDefaultStop=""\ # nodeService_install nodeService_install() { local log="nodeService_install" shErrorOnMissing "pName pServiceInfo pServiceDoc" shErrorOnMissing "pChrootDir pUser pGroup pMountFolders" shWarnOnMissing "pStart pPreStart pStop pReload pIdFile serviceType pDirUserGroupRight" if [ -z "$pIdFile" ];then local pIdFile="$pChrootDir/var/run/$pName/$pName.pid";fi # shWarnOnMissing "pSystemCtlWants pSystemCtlBefore pSystemCtlAfter" shWarnOnMissing "pInitVRequiredStart pInitVRequiredStop" if [ -z "$pInitVRequiredStart" ];then local pInitVRequiredStart="\$remote_fs";fi if [ -z "$pInitVRequiredStop" ];then local pInitVRequiredStop="\$remote_fs";fi shWarnOnMissing "pInitVShouldStart pInitVShouldStop" if [ -z "$pInitVShouldStart" ];then local pInitVShouldStart="\$network \$syslog";fi if [ -z "$pInitVShouldStop" ];then local pInitVShouldStop="\$network \$syslog";fi shWarnOnMissing "pInitVDefaultStart pInitVDefaultStop" if [ -z "$pInitVDefaultStart" ];then local pInitVDefaultStart="2 3 4 5";fi if [ -z "$pInitVDefaultStop" ];then local pInitVDefaultStop="0 1 6";fi #pName="$pName" pServiceInfo="$pServiceInfo" pServiceDoc="$pServiceDoc" \ pInitVRequiredStart="$pInitVRequiredStart" pInitVRequiredStop="$pInitVRequiredStop" \ pInitVShouldStart="$pInitVShouldStart" pInitVShouldStop="$pInitVShouldStop" \ pInitVDefaultStart="$pInitVDefaultStart" pInitVDefaultStop="$pInitVDefaultStop" \ services_initv_unit_gen > /etc/node/${pName} # pName="$pName" pStart="$pStart" pStartPre="$pStartPre" pStop="$pStop" pReload="$pReload" pIdFile="$pIdFile"\ # pUser="$pUser" pGroup="$pGroup" pChrootDir="$pChrootDir" pMountFolders="$pMountFolders" pDirUserGroupRight="$pDirUserGroupRight"\ pIdFile="$pIdFile"\ services_initv_gen >> /etc/node/${pName} $cmdChmod u+x /etc/node/${pName} } # pDebugFile="$pDebugFile" pName="$pName" pChrootDir="$pChrootDir"\ # pUser="$pUser" pGroup="$pGroup" ExecStart="$ExecStart" pMountFolders="$pMountFolders"\ # pDirUserGroupRight="$pDirUserGroupRight" # nodeService_install_debug nodeService_install_debug() { local log="nodeService_install_debug" shErrorOnMissing "pDebugFile pName pChrootDir pUser pGroup" shErrorOnMissing "ExecStart pMountFolders" shWarnOnMissing "pDirUserGroupRight" 1>&2 $cmdEcho -e "#!/bin/sh \n\ if ! type \"shInclude\" > /dev/null; then \n\ racineSh=\"\${racineSh:-$racineSh}\" \n\ . \$racineSh/lib/shTools \n\ fi \n\ rootDarkContainer=\"\${rootDarkContainer:-$rootDarkContainer}\" \n\ \$(shInclude \$rootDarkContainer/lib/chroot) \n\ " > "$pDebugFile" for myParams in bash ls ldd gdb strace ldconfig ldconfig.real;do $cmdEcho -e "cmd=\"\$(which $myParams)\" \n\ if [ -n \"\$cmd\" ];then chroot_install \"$pChrootDir\" \"\$cmd\" ;fi \n\ " >> "$pDebugFile" done $cmdEcho -e "/etc/node/$pName stop \n\ " >> "$pDebugFile" $cmdChmod u+x "$pDebugFile" #chroot_gen_start "$pChrootDir" "$pUser" "$pGroup" "$pMountFolders" $cmdEcho -e "dataFile=\"$rootDarkContainer/data/$(echo $pChrootDir | base64)\"" >> "$pDebugFile" $cmdEcho -e "$rootDarkContainer/bin/container start \"\$dataFile\"" >> "$pDebugFile" $cmdEcho -e "$cmdEcho -e \"ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache\"" >> "$pDebugFile" $cmdEcho -e "$cmdEcho -e \"$ExecStart\"" >> "$pDebugFile" $cmdEcho -e "$cmdChroot $pChrootDir" >> "$pDebugFile" $cmdEcho -e "$rootDarkContainer/bin/container stop \"\$dataFile\"" >> "$pDebugFile" }