#!/bin/sh # ===================================================================== # Projet : DARKCONTAINER # Fichier : lib/services # 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 | grep | rev | #|--------------------------------------------------------------------------| # &&&&& #|-----------------------------------------------------------------------| #| 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/service-systemctl) $(shInclude $rootDarkContainer/lib/service-initv) cmdSh="${cmdSh:-$(which sh)}" # pName="$pName" services_create services_create() { local log="services_create:" shErrorOnMissing "pName" if [ ! -x "$cmdSystemctl" ];then shDebug 1 ""$log" not systemctl system, gone to initV" services_initv_create "$pName" else services_systemctl_create "$pName" fi } #pName="$pName" pServiceInfo="$pServiceInfo" pServiceDoc="$pServiceDoc"\ #pStart="$pStart" pStartPre="$pStartPre" pStop="$pStop" pReload="$pReload"\ #pIdFile="$pIdFile" serviceType="$serviceType"\ #pSystemCtlWants="$pSystemCtlWants" pSystemCtlBefore="$pSystemCtlBefore" pSystemCtlAfter="$pSystemCtlAfter" pSystemCtlRequires="$pSystemCtlRequires"\ #pInitVRequiredStart="$pInitVRequiredStart" pInitVRequiredStop="$pInitVRequiredStop"\ #pInitVShouldStart="$pInitVShouldStart" pInitVShouldStop="$pInitVShouldStop"\ #pInitVDefaultStart="$pInitVDefaultStart" pInitVDefaultStop="$pInitVDefaultStop"\ #services_install services_install () { local log="services_install" shErrorOnMissing "pName pServiceInfo pServiceDoc pStart" shWarnOnMissing "pIdFile pReload pStartPre pStop serviceType" if [ -z "$serviceType" ];then local serviceType="forking";fi if [ -z "$pIdFile" ];then local pIdFile="/var/run/$pName/$pName.pid";fi # if [ -z "$pIdFile" ];then pIdFile="/var/run/$pName/$pName.pid";fi shWarnOnMissing "pSystemCtlWants pSystemCtlBefore pSystemCtlAfter pSystemCtrlRequires" # if [ -z "$pSystemCtlWants" ];then local pSystemCtlWants="nss-lookup.target";fi # if [ -z "$pSystemCtlBefore" ];then local pSystemCtlBefore="nss-lookup.target";fi # if [ -z "$pSystemCtlAfter" ];then local pSystemCtlAfter="network.target";fi # if [ -z "$pSystemCtlAfter" ];then local pSystemCtlRequires="network.target";fi 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 # shErrorOnMissing "pSystemCtlWants pSystemCtlBefore pSystemCtlAfter" # shErrorOnMissing "pInitVRequiredStart pInitVRequiredStop" # shErrorOnMissing "pInitVShouldStart pInitVShouldStop" # shErrorOnMissing "pInitVDefaultStart pInitVDefaultStop" if [ -z "$cmdSystemctl" ];then shDebug 1 ""$log" not systemctl system, gone to initV" #pName="$pName" pServiceInfo="$pServiceInfo" pServiceDoc="$pServiceDoc"\ #pStart="$pStart" pStartPre="$pStartPre" pStop="$pStop" pReload="$pReload"\ pIdFile="$pChrootDir/$pIdFile" serviceType="$serviceType" \ pInitVRequiredStart="$pInitVRequiredStart" pInitVRequiredStop="$pInitVRequiredStop" \ pInitVShouldStart="$pInitVShouldStart" pInitVShouldStop="$pInitVShouldStop" \ pInitVDefaultStart="$pInitVDefaultStart" pInitVDefaultStop="$pInitVDefaultStop" \ services_initv_install else #pName="$pName" pServiceInfo="$pServiceInfo" pServiceDoc="$pServiceDoc"\ #pStart="$pStart" pStartPre="$pStartPre" pStop="$pStop" pReload="$pReload"\ pIdFile="$pChrootDir/$pIdFile" serviceType="$serviceType" \ pSystemCtlWants="$pSystemCtlWants" pSystemCtlBefore="$pSystemCtlBefore" pSystemCtlAfter="$pSystemCtlAfter" pSystemCtlRequires="$pSystemCtlRequires"\ services_systemctl_install fi } # debugFile="$debugFile" pName="$pName" pStart="$pStart" # services_install_debug services_install_debug() { local log="services_systemctl_install_debug" shErrorOnMissing "debugFile pName pStart" shErrorOnMissing "cmdEcho" shWarnOnMissing "pChrootDir" $cmdEcho -e "#!/bin/sh \n\ if ! type \"shInclude\" > /dev/null; then \n\ racineSh=\"\${racineSh:-$racineSh}\";. \$racineSh/lib/shTools; \n\ fi \n\ if [ -x \"$cmdSystemctl\" ];then \n\ $cmdSystemctl stop "$pName" \n\ else \n\ /etc/init.d/$pName stop \n\ fi \n\ $cmdEcho -e \"ldconfig -f /etc/ld.so.conf -C /etc/ld.so.cache\" \n\ rootDarkContainer=\"\${rootDarkContainer:-$rootDarkContainer}\" \n\ if [ -n \"$pChrootDir\" ];then \n\ \$(shInclude \$rootDarkContainer/lib/chroot) \n\ for myParams in bash ls ldd gdb strace ldconfig ldconfig.real;do \n\ cmd=\"\$(which $myParams)\" \n\ if [ -n \"\$cmd\" ];then chroot_install \"$pChrootDir\" \"\$cmd\" ;fi \n\ done \n\ dataFile=\"\$rootDarkContainer/data/\$(echo $pChrootDir | base64 -i)\" \n\ sh \"\$rootDarkContainer/bin/container\" start \"\$dataFile\" \n\ fi \n\ $cmdEcho -e \"$pStart\" \n\ if [ -n \"$pChrootDir\" ];then \n\ $cmdChroot $pChrootDir $(which sh) \n\ sh \"\$rootDarkContainer/bin/container\" stop \"\$dataFile\" \n\ fi \n\ " > "$debugFile" $cmdChmod u+x "$debugFile" }