Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
6
66
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eric Vidal
66
Commits
3f628784
Commit
3f628784
authored
6 years ago
by
Eric Vidal
Browse files
Options
Downloads
Patches
Plain Diff
enable,disable: add -S features for start/stop after enable/disable the service
parent
01920a69
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/66/66-disable.c
+35
-4
35 additions, 4 deletions
src/66/66-disable.c
src/66/66-enable.c
+34
-4
34 additions, 4 deletions
src/66/66-enable.c
with
69 additions
and
8 deletions
src/66/66-disable.c
+
35
−
4
View file @
3f628784
...
...
@@ -46,7 +46,7 @@ stralloc saresolve = STRALLOC_ZERO ;
unsigned
int
VERBOSITY
=
1
;
#define USAGE "66-enable [ -h help ] [ -v verbosity ] [ - l live ] [ -t tree ] service(s)"
#define USAGE "66-enable [ -h help ] [ -v verbosity ] [ - l live ] [ -t tree ]
[ -S stop ]
service(s)"
static
inline
void
info_help
(
void
)
{
...
...
@@ -58,6 +58,7 @@ static inline void info_help (void)
" -v: increase/decrease verbosity
\n
"
" -l: live directory
\n
"
" -t: name of the tree to use
\n
"
" -S: disable and stop the service
\n
"
;
if
(
buffer_putsflush
(
buffer_1
,
help
)
<
0
)
...
...
@@ -298,7 +299,7 @@ int remove_sv(char const *src, char const *name,unsigned int type,genalloc *tore
int
main
(
int
argc
,
char
const
*
const
*
argv
,
char
const
*
const
*
envp
)
{
int
r
,
rb
;
unsigned
int
nlongrun
,
nclassic
;
unsigned
int
nlongrun
,
nclassic
,
stop
;
uid_t
owner
;
...
...
@@ -311,7 +312,8 @@ int main(int argc, char const *const *argv,char const *const *envp)
genalloc
ganlong
=
GENALLOC_ZERO
;
//name of longrun service, type stralist
genalloc
ganclassic
=
GENALLOC_ZERO
;
//name of classic service, stralist
genalloc
gadepstoremove
=
GENALLOC_ZERO
;
r
=
nclassic
=
nlongrun
=
0
;
r
=
nclassic
=
nlongrun
=
stop
=
0
;
PROG
=
"66-disable"
;
{
...
...
@@ -319,7 +321,7 @@ int main(int argc, char const *const *argv,char const *const *envp)
for
(;;)
{
int
opt
=
getopt_args
(
argc
,
argv
,
">hv:l:t:"
,
&
l
)
;
int
opt
=
getopt_args
(
argc
,
argv
,
">hv:l:t:
S
"
,
&
l
)
;
if
(
opt
==
-
1
)
break
;
if
(
opt
==
-
2
)
strerr_dief1x
(
110
,
"options must be set first"
)
;
switch
(
opt
)
...
...
@@ -332,6 +334,7 @@ int main(int argc, char const *const *argv,char const *const *envp)
case
't'
:
if
(
!
stralloc_cats
(
&
tree
,
l
.
arg
))
retstralloc
(
111
,
"main"
)
;
if
(
!
stralloc_0
(
&
tree
))
retstralloc
(
111
,
"main"
)
;
break
;
case
'S'
:
stop
=
1
;
break
;
default
:
exitusage
()
;
}
}
...
...
@@ -633,6 +636,34 @@ int main(int argc, char const *const *argv,char const *const *envp)
cleanup
(
workdir
.
s
)
;
if
(
stop
)
{
size_t
arglen
=
9
+
genalloc_len
(
stralist
,
&
ganclassic
)
+
genalloc_len
(
stralist
,
&
ganlong
)
;
char
const
*
newstop
[
arglen
]
;
unsigned
int
m
=
0
;
char
fmt
[
UINT_FMT
]
;
fmt
[
uint_fmt
(
fmt
,
VERBOSITY
)]
=
0
;
newstop
[
m
++
]
=
SS_BINPREFIX
"66-stop"
;
newstop
[
m
++
]
=
"-v"
;
newstop
[
m
++
]
=
fmt
;
newstop
[
m
++
]
=
"-l"
;
newstop
[
m
++
]
=
live
.
s
;
newstop
[
m
++
]
=
"-t"
;
newstop
[
m
++
]
=
treename
;
newstop
[
m
++
]
=
"-u"
;
/** classic */
for
(
unsigned
int
i
=
0
;
i
<
genalloc_len
(
stralist
,
&
ganclassic
);
i
++
)
newstop
[
m
++
]
=
gaistr
(
&
ganclassic
,
i
)
;
/** rc */
for
(
unsigned
int
i
=
0
;
i
<
genalloc_len
(
stralist
,
&
ganlong
);
i
++
)
newstop
[
m
++
]
=
gaistr
(
&
ganlong
,
i
)
;
newstop
[
m
++
]
=
0
;
xpathexec_run
(
newstop
[
0
],
newstop
,
envp
)
;
}
stralloc_free
(
&
base
)
;
stralloc_free
(
&
tree
)
;
stralloc_free
(
&
workdir
)
;
...
...
This diff is collapsed.
Click to expand it.
src/66/66-enable.c
+
34
−
4
View file @
3f628784
...
...
@@ -47,7 +47,7 @@ unsigned int VERBOSITY = 1 ;
stralloc
saresolve
=
STRALLOC_ZERO
;
#define USAGE "66-enable [ -h help ] [ -v verbosity ] [ - l live ] [ -t tree ] [ -f force ] [ -d directory ] [ -I instance ] service(s)"
#define USAGE "66-enable [ -h help ] [ -v verbosity ] [ - l live ] [ -t tree ] [ -f force ] [ -d directory ] [ -I instance ]
[ -S start ]
service(s)"
static
inline
void
info_help
(
void
)
{
...
...
@@ -62,6 +62,7 @@ static inline void info_help (void)
" -f: owerwrite service(s)
\n
"
" -d: enable an entire directory
\n
"
" -I: create an instance of service
\n
"
" -S: enable and start the service
\n
"
;
if
(
buffer_putsflush
(
buffer_1
,
help
)
<
0
)
...
...
@@ -159,7 +160,7 @@ int insta_create(char const *src,char const *instasrc, char const *instacopy, ch
int
main
(
int
argc
,
char
const
*
const
*
argv
,
char
const
*
const
*
envp
)
{
int
r
;
unsigned
int
nbsv
,
nlongrun
,
nclassic
,
insta
;
unsigned
int
nbsv
,
nlongrun
,
nclassic
,
insta
,
start
;
uid_t
owner
;
...
...
@@ -178,7 +179,7 @@ int main(int argc, char const *const *argv,char const *const *envp)
genalloc
ganlong
=
GENALLOC_ZERO
;
// type stralist
genalloc
ganclassic
=
GENALLOC_ZERO
;
// name of classic service, type stralist
r
=
nbsv
=
nclassic
=
nlongrun
=
insta
=
0
;
r
=
nbsv
=
nclassic
=
nlongrun
=
insta
=
start
=
0
;
PROG
=
"66-enable"
;
{
...
...
@@ -186,7 +187,7 @@ int main(int argc, char const *const *argv,char const *const *envp)
for
(;;)
{
int
opt
=
getopt_args
(
argc
,
argv
,
">hv:l:t:fd:I:"
,
&
l
)
;
int
opt
=
getopt_args
(
argc
,
argv
,
">hv:l:t:fd:I:
S
"
,
&
l
)
;
if
(
opt
==
-
1
)
break
;
if
(
opt
==
-
2
)
strerr_dief1x
(
110
,
"options must be set first"
)
;
switch
(
opt
)
...
...
@@ -208,6 +209,7 @@ int main(int argc, char const *const *argv,char const *const *envp)
instacopy
=
l
.
arg
;
insta
=
1
;
break
;
case
'S'
:
start
=
1
;
break
;
default
:
exitusage
()
;
}
}
...
...
@@ -317,6 +319,7 @@ int main(int argc, char const *const *argv,char const *const *envp)
}
else
if
(
before
.
services
[
i
].
cname
.
itype
==
CLASSIC
)
{
if
(
!
stra_add
(
&
ganclassic
,
keep
.
s
+
before
.
services
[
i
].
cname
.
name
))
retstralloc
(
111
,
"main"
)
;
nclassic
++
;
}
}
...
...
@@ -473,7 +476,34 @@ int main(int argc, char const *const *argv,char const *const *envp)
}
cleanup
(
workdir
.
s
)
;
if
(
start
)
{
size_t
arglen
=
8
+
genalloc_len
(
stralist
,
&
ganclassic
)
+
genalloc_len
(
stralist
,
&
ganlong
)
;
char
const
*
newup
[
arglen
]
;
unsigned
int
m
=
0
;
char
fmt
[
UINT_FMT
]
;
fmt
[
uint_fmt
(
fmt
,
VERBOSITY
)]
=
0
;
newup
[
m
++
]
=
SS_BINPREFIX
"66-start"
;
newup
[
m
++
]
=
"-v"
;
newup
[
m
++
]
=
fmt
;
newup
[
m
++
]
=
"-l"
;
newup
[
m
++
]
=
live
.
s
;
newup
[
m
++
]
=
"-t"
;
newup
[
m
++
]
=
treename
;
/** classic */
for
(
unsigned
int
i
=
0
;
i
<
genalloc_len
(
stralist
,
&
ganclassic
);
i
++
)
newup
[
m
++
]
=
gaistr
(
&
ganclassic
,
i
)
;
/** rc */
for
(
unsigned
int
i
=
0
;
i
<
genalloc_len
(
stralist
,
&
ganlong
);
i
++
)
newup
[
m
++
]
=
gaistr
(
&
ganlong
,
i
)
;
newup
[
m
++
]
=
0
;
xpathexec_run
(
newup
[
0
],
newup
,
envp
)
;
}
/** general allocation*/
freed_parser
()
;
/** inner allocation */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment