Subversion Repositories php-qbpwcf

Rev

Rev 3 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 226
Line 1... Line 1...
1
#!/usr/bin/php
1
#!/usr/bin/php
2
<?php
2
<?php
3
 
3
 
4
/*
4
/*
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
5
	QBPWCF, Quick Build PHP website Component base on Fedora Linux.
6
    Copyright (C) 2015~2024 Min-Jhin,Chen
6
    Copyright (C) 2014~2025 MIN ZHI, CHEN
7
 
7
 
8
    This file is part of QBPWCF.
8
    This file is part of QBPWCF.
9
 
9
 
10
    QBPWCF is free software: you can redistribute it and/or modify
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
11
    it under the terms of the GNU General Public License as published by
Line 17... Line 17...
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
    GNU General Public License for more details.
18
    GNU General Public License for more details.
19
 
19
 
20
    You should have received a copy of the GNU General Public License
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/>.
21
    along with QBPWCF.  If not, see <http://www.gnu.org/licenses/>.
22
    
22
 
23
*/
23
*/
24
 
24
 
25
/*
25
/*
26
安裝方式:
26
安裝方式:
27
將該檔案移動到 /usr/bin/ 底下
27
將該檔案移動到 /usr/bin/ 底下
Line 63... Line 63...
63
	#結束執行,回傳shell 1.
63
	#結束執行,回傳shell 1.
64
	exit(1);
64
	exit(1);
65
 
65
 
66
	}#if end
66
	}#if end
67
 
67
 
68
#設置 include path 
68
#設置 include path
69
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
69
set_include_path($output[0].PATH_SEPARATOR.get_include_path());
70
 
70
 
71
#匯入外部套件
71
#匯入外部套件
72
include("allInOne.php");
72
include("allInOne.php");
73
 
73
 
74
#無窮迴圈
74
#無窮迴圈
75
while(true){
75
while(true){
76
	
76
 
77
	#查詢服務啟動沒
77
	#查詢服務啟動沒
78
	#涵式說明:
78
	#涵式說明:
79
	#執行 systemd 程序來管理服務.
79
	#執行 systemd 程序來管理服務.
80
	#回傳結果:
80
	#回傳結果:
81
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
81
	#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
82
	#$result["error"],錯誤訊息.
82
	#$result["error"],錯誤訊息.
83
	#$result["function"],當前執行的函數名稱.
83
	#$result["function"],當前執行的函數名稱.
84
	#$result["argu"],所使用的參數.
84
	#$result["argu"],所使用的參數.
85
	#$result["content"],執行的結果.
85
	#$result["content"],執行的結果.
86
	#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
86
	#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行.
87
	#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
87
	#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動.
88
	#必填參數:
88
	#必填參數:
89
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
89
	#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
90
	$conf["fileArgu"]=__FILE__;
90
	$conf["fileArgu"]=__FILE__;
91
	#$conf["name"],字串,服務名稱.
91
	#$conf["name"],字串,服務名稱.
92
	$conf["name"]="mariadb";
92
	$conf["name"]="mariadb";
Line 97... Line 97...
97
	#$conf["username"]="";
97
	#$conf["username"]="";
98
	#$conf["password"],字串,使用者的密碼,預設不使用.
98
	#$conf["password"],字串,使用者的密碼,預設不使用.
99
	#$conf["password"]="";
99
	#$conf["password"]="";
100
	$systemd=cmd::systemd($conf);
100
	$systemd=cmd::systemd($conf);
101
	unset($conf);
101
	unset($conf);
102
	
102
 
103
	#若運行出錯
103
	#若運行出錯
104
	if($systemd["status"]==="false"){
104
	if($systemd["status"]==="false"){
105
	
105
 
106
		#debug
106
		#debug
107
		var_dump($systemd);
107
		var_dump($systemd);
108
		
108
 
109
		#停止執行
109
		#停止執行
110
		exit;
110
		exit;
111
	
111
 
112
		}#if end
112
		}#if end
113
		
113
 
114
	#如果服務沒啟動
114
	#如果服務沒啟動
115
	if($systemd["content"]["srerviceInfo"]["on"]==="false"){
115
	if($systemd["content"]["srerviceInfo"]["on"]==="false"){
116
	
116
 
117
		#啟動服務
117
		#啟動服務
118
		#涵式說明:
118
		#涵式說明:
119
		#執行 systemd 程序來管理服務.
119
		#執行 systemd 程序來管理服務.
120
		#回傳結果:
120
		#回傳結果:
121
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
121
		#$result["status"],執行是否正常,"true"代表正常,"false"代表不正常.
122
		#$result["error"],錯誤訊息.
122
		#$result["error"],錯誤訊息.
123
		#$result["function"],當前執行的函數名稱.
123
		#$result["function"],當前執行的函數名稱.
124
		#$result["argu"],所使用的參數.
124
		#$result["argu"],所使用的參數.
125
		#$result["content"],執行的結果.
125
		#$result["content"],執行的結果.
126
		#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行. 
126
		#$result["content"]["srerviceInfo"]["on"],"true",代表運行中,"false",代表無運行.
127
		#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動. 
127
		#$result["content"]["srerviceInfo"]["auto"],"true",代表自動啟動,"false",代表不自動啟動.
128
		#必填參數:
128
		#必填參數:
129
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
129
		#$conf["fileArgu"],字串,php變數__FILE__的內容,亦即該檔案在檔案系統的絕對路徑
130
		$conf["fileArgu"]=__FILE__;
130
		$conf["fileArgu"]=__FILE__;
131
		#$conf["name"],字串,服務名稱.
131
		#$conf["name"],字串,服務名稱.
132
		$conf["name"]="mariadb";
132
		$conf["name"]="mariadb";
Line 137... Line 137...
137
		#$conf["username"]="";
137
		#$conf["username"]="";
138
		#$conf["password"],字串,使用者的密碼,預設不使用.
138
		#$conf["password"],字串,使用者的密碼,預設不使用.
139
		#$conf["password"]="";
139
		#$conf["password"]="";
140
		$systemd=cmd::systemd($conf);
140
		$systemd=cmd::systemd($conf);
141
		unset($conf);
141
		unset($conf);
142
		
142
 
143
		#若運行出錯
143
		#若運行出錯
144
		if($systemd["status"]==="false"){
144
		if($systemd["status"]==="false"){
145
		
145
 
146
			#debug
146
			#debug
147
			var_dump($systemd);
147
			var_dump($systemd);
148
			
148
 
149
			#停止執行
149
			#停止執行
150
			exit;
150
			exit;
151
		
151
 
152
			}#if end
152
			}#if end
153
	
153
 
154
		}#if end
154
		}#if end
155
		
155
 
156
	#過30秒再檢查一次
156
	#過30秒再檢查一次
157
	sleep(30);
157
	sleep(30);
158
	
158
 
159
	#下一輪
159
	#下一輪
160
	continue;
160
	continue;
161
	
161
 
162
	}#while end
162
	}#while end
163
 
163
 
164
?>
164
?>