@@ -5,19 +5,18 @@ package daemon
55import  "C" 
66
77import  (
8- 	"unsafe" 
9- 	"fmt" 
108	"bytes" 
11- 	"path/filepath" 
9+ 	"fmt" 
10+ 	"io/ioutil" 
1211	"os" 
1312	"os/exec" 
13+ 	"path/filepath" 
1414	"regexp" 
1515	"strings" 
1616	"text/template" 
17- 	"io/ioutil " 
17+ 	"unsafe " 
1818)
1919
20- 
2120// systemVRecord - standard record (struct) for linux systemV version of daemon package 
2221type  bsdRecord  struct  {
2322	name          string 
@@ -52,19 +51,18 @@ func (bsd *bsdRecord) isEnabled() (bool, error) {
5251	r , _  :=  regexp .Compile (`.*`  +  bsd .name  +  `_enable="YES".*` )
5352	v  :=  string (r .Find (rcData ))
5453	var  chrFound , sharpFound  bool 
55- 	for  _ , c  :=  range ( v ) {
56- 		if  c  ==  '#'  &&  ! chrFound {
54+ 	for  _ , c  :=  range   v   {
55+ 		if  c  ==  '#'  &&  ! chrFound   {
5756			sharpFound  =  true 
5857			break 
59- 		}else  if  ! sharpFound  &&  c  !=  ' ' {
58+ 		}  else  if  ! sharpFound  &&  c  !=  ' '   {
6059			chrFound  =  true 
6160			break 
6261		}
6362	}
6463	return  chrFound , nil 
6564}
6665
67- 
6866func  (bsd  * bsdRecord ) getCmd (cmd  string ) string  {
6967	if  ok , err  :=  bsd .isEnabled (); ! ok  ||  err  !=  nil  {
7068		fmt .Println ("Service is not enabled, using one"  +  cmd  +  " instead" )
@@ -73,7 +71,6 @@ func (bsd *bsdRecord) getCmd(cmd string) string {
7371	return  cmd 
7472}
7573
76- 
7774// Get the daemon properly 
7875func  newDaemon (name , description  string , dependencies  []string ) (Daemon , error ) {
7976	return  & bsdRecord {name , description , dependencies }, nil 
@@ -111,7 +108,6 @@ func execPath() (string, error) {
111108	return  filepath .Clean (exePathString ), nil 
112109}
113110
114- 
115111// Check service is running 
116112func  (bsd  * bsdRecord ) checkRunning () (string , bool ) {
117113	output , err  :=  exec .Command ("service" , bsd .name , bsd .getCmd ("status" )).Output ()
@@ -194,7 +190,6 @@ func (bsd *bsdRecord) Remove() (string, error) {
194190	return  removeAction  +  success , nil 
195191}
196192
197- 
198193// Start the service 
199194func  (bsd  * bsdRecord ) Start () (string , error ) {
200195	startAction  :=  "Starting "  +  bsd .description  +  ":" 
@@ -280,4 +275,3 @@ start_cmd="/usr/sbin/daemon -p $pidfile -f $command {{.Args}}"
280275load_rc_config $name 
281276run_rc_command "$1" 
282277` 
283- 
0 commit comments