@@ -1856,23 +1856,46 @@ function umount_backup_dir($backup_dir, $mount_cmd = '/usr/local/ispconfig/serve
18561856
18571857 }
18581858
1859- function getinitcommand ($ servicename , $ action , $ init_script_directory = '' ) {
1859+ function _getinitcommand ($ servicename , $ action , $ init_script_directory = '' , $ check_service ) {
18601860 global $ conf ;
18611861 // upstart
18621862 if (is_executable ('/sbin/initctl ' )){
18631863 exec ('/sbin/initctl version 2>/dev/null | /bin/grep -q upstart ' , $ retval ['output ' ], $ retval ['retval ' ]);
18641864 if (intval ($ retval ['retval ' ]) == 0 ) return 'service ' .$ servicename .' ' .$ action ;
18651865 }
1866+
18661867 // systemd
18671868 if (is_executable ('/bin/systemd ' ) || is_executable ('/usr/bin/systemctl ' )){
1868- return 'systemctl ' .$ action .' ' .$ servicename .'.service ' ;
1869+ if ($ check_service ) {
1870+ exec ("systemctl is-enabled " .$ servicename ." 2>&1 " , $ out , $ ret_val );
1871+ }
1872+ if ($ ret_val == 0 || !$ check_service ) {
1873+ return 'systemctl ' .$ action .' ' .$ servicename .'.service ' ;
1874+ }
18691875 }
1876+
18701877 // sysvinit
18711878 if ($ init_script_directory == '' ) $ init_script_directory = $ conf ['init_scripts ' ];
18721879 if (substr ($ init_script_directory , -1 ) === '/ ' ) $ init_script_directory = substr ($ init_script_directory , 0 , -1 );
1873- return $ init_script_directory .'/ ' .$ servicename .' ' .$ action ;
1880+ if ($ check_service && is_executable ($ init_script_directory .'/ ' .$ servicename )) {
1881+ return $ init_script_directory .'/ ' .$ servicename .' ' .$ action ;
1882+ }
1883+ if (!$ check_service ) {
1884+ return $ init_script_directory .'/ ' .$ servicename .' ' .$ action ;
1885+ }
18741886 }
1875-
1887+
1888+ function getinitcommand ($ servicename , $ action , $ init_script_directory = '' , $ check_service =false ) {
1889+ if (is_array ($ servicename )) {
1890+ foreach ($ servicename as $ service ) {
1891+ $ out = $ this ->_getinitcommand ($ service , $ action , $ init_script_directory , true );
1892+ if ($ out != '' ) return $ out ;
1893+ }
1894+ } else {
1895+ return $ this ->_getinitcommand ($ servicename , $ action , $ init_script_directory , $ check_service );
1896+ }
1897+ }
1898+
18761899 function getapacheversion ($ get_minor = false ) {
18771900 global $ app ;
18781901
0 commit comments