| 11 |
liveuser |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
|
|
|
5 |
QBPWCF, Quick Build PHP website Component base on Fedora Linux.
|
| 239 |
liveuser |
6 |
Copyright (C) 2014~2026 MIN ZHI, CHEN
|
| 11 |
liveuser |
7 |
|
|
|
8 |
This file is part of QBPWCF.
|
|
|
9 |
|
|
|
10 |
QBPWCF is free software: you can redistribute it and/or modify
|
|
|
11 |
it under the terms of the GNU General Public License as published by
|
|
|
12 |
the Free Software Foundation, either version 3 of the License, or
|
|
|
13 |
(at your option) any later version.
|
|
|
14 |
|
|
|
15 |
QBPWCF is distributed in the hope that it will be useful,
|
|
|
16 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
17 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
18 |
GNU General Public License for more details.
|
|
|
19 |
|
|
|
20 |
You should have received a copy of the GNU General Public License
|
|
|
21 |
along with QBPWCF. If not, see <http://www.gnu.org/licenses/>.
|
|
|
22 |
|
|
|
23 |
*/
|
|
|
24 |
|
|
|
25 |
#使用命名空間qbpwcf
|
|
|
26 |
namespace qbpwcf;
|
|
|
27 |
|
|
|
28 |
#assets dir
|
|
|
29 |
$assetsDir="assets of cmd::register_20241125";
|
|
|
30 |
|
|
|
31 |
#函式說明:
|
|
|
32 |
#將要執行的程式變成透過 systemd 來運行.
|
|
|
33 |
#回傳結果:
|
|
|
34 |
#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
|
|
|
35 |
#$result["error"],錯誤訊息.
|
|
|
36 |
#$result["function"],當前執行的函式名稱.
|
|
|
37 |
#$result["argu"],所使用的參數.
|
|
|
38 |
#$result["content"],執行的結果.
|
|
|
39 |
#必填參數:
|
|
|
40 |
#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑.
|
|
|
41 |
$conf["fileArgu"]=__FILE__;
|
|
|
42 |
#$conf["name"],字串,服務名稱,實際產生的system名稱會加上".service".
|
|
|
43 |
$conf["name"]="cmd::registerService:20241125";
|
|
|
44 |
#$conf["cmd"],要執行的指令與參數,字串陣列.
|
|
|
45 |
$conf["cmd"]="dmesg";
|
|
|
46 |
#可省略參數:
|
|
|
47 |
#$conf["params"],字串陣列,要使用的參數.
|
|
|
48 |
$conf["params"]=array("-T");
|
|
|
49 |
#$conf["enable"],字串,預設為"true",代表該服務為enable.
|
|
|
50 |
$conf["enable"]="true";
|
|
|
51 |
#$conf["startNow"],字串,預設為"true",代表該服務要立刻舉辦.
|
|
|
52 |
$conf["startNow"]="true";
|
|
|
53 |
#參考資料:
|
|
|
54 |
#無.
|
|
|
55 |
#備註:
|
|
|
56 |
#無.
|
|
|
57 |
$registerService=cmd::registerService($conf);
|
|
|
58 |
unset($conf);
|
|
|
59 |
|
|
|
60 |
#如果執行失敗
|
|
|
61 |
if($registerService["status"]==="false"){
|
|
|
62 |
|
|
|
63 |
#debug
|
|
|
64 |
var_dump($registerService);
|
|
|
65 |
|
| 226 |
liveuser |
66 |
}#if end
|