Skip to content

Commit 0c99754

Browse files
ahspwshaerpour
authored andcommitted
CPACK: add auto generated dbhelper maintainer scripts
Signed-off-by: ahspw <ahspvirtuallife@gmail.com>
1 parent 9885705 commit 0c99754

File tree

6 files changed

+154
-0
lines changed

6 files changed

+154
-0
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,7 @@ else()
12101210
set(FLB_INSTALL_BINDIR ${CMAKE_INSTALL_FULL_BINDIR})
12111211
set(FLB_INSTALL_LIBDIR "${CMAKE_INSTALL_LIBDIR}/${FLB_OUT_NAME}")
12121212
set(FLB_INSTALL_CONFDIR "${CMAKE_INSTALL_SYSCONFDIR}/${FLB_OUT_NAME}/")
1213+
set(FLB_INSTALL_INITDIR "/etc/init.d/")
12131214
set(FLB_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include")
12141215
endif()
12151216

@@ -1290,6 +1291,9 @@ if(DPKG_PROGRAM)
12901291
set(CPACK_DEBIAN_RUNTIME_FILE_NAME "${CPACK_PACKAGE_NAME}_${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}.deb")
12911292
set(CPACK_DEBIAN_RUNTIME_PACKAGE_CONTROL_EXTRA
12921293
${PROJECT_SOURCE_DIR}/cpack/debian/conffiles
1294+
${PROJECT_SOURCE_DIR}/cpack/debian/prerm
1295+
${PROJECT_SOURCE_DIR}/cpack/debian/postinst
1296+
${PROJECT_SOURCE_DIR}/cpack/debian/postrm
12931297
)
12941298

12951299
if(FLB_RUN_LDCONFIG)

conf/fluent-bit

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/sh
2+
3+
### BEGIN INIT INFO
4+
# Provides: fluent-bit
5+
# Required-Start: $local_fs $remote_fs $network $syslog $named
6+
# Required-Stop: $local_fs $remote_fs $network $syslog $named
7+
# Default-Start: 2 3 4 5
8+
# Default-Stop: 0 1 6
9+
# Short-Description: starts the fluent-bit service
10+
# Description: starts fluent-bit using start-stop-daemon
11+
### END INIT INFO
12+
13+
PATH=/opt/fluent-bit/bin/:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
14+
DAEMON=/opt/fluent-bit/bin/fluent-bit
15+
NAME=fluent-bit
16+
DESC=fluent-bit
17+
18+
start_fluent_bit() {
19+
# Start the daemon/service
20+
#
21+
# Returns:
22+
# 0 if daemon has been started
23+
# 1 if daemon was already running
24+
# 2 if daemon could not be started
25+
start-stop-daemon --start --quiet --exec $DAEMON 2>/dev/null || return 2
26+
}
27+
28+
test_config() {
29+
# Test the fluent_bit configuration
30+
$DAEMON --dry-run -c /etc/fluent-bit/fluent-bit.conf
31+
}
32+
33+
stop_fluent_bit() {
34+
# Stops the daemon/service
35+
#
36+
# Return
37+
# 0 if daemon has been stopped
38+
# 1 if daemon was already stopped
39+
# 2 if daemon could not be stopped
40+
# other if a failure occurred
41+
start-stop-daemon --stop --quiet --name $NAME
42+
}
43+
44+
case "$1" in
45+
start)
46+
start_fluent_bit
47+
;;
48+
stop)
49+
stop_fluent_bit
50+
;;
51+
restart)
52+
53+
# Check configuration before stopping fluent_bit
54+
if ! test_config; then
55+
exit $?
56+
fi
57+
58+
stop_fluent_bit
59+
case "$?" in
60+
0|1)
61+
start_fluent_bit
62+
;;
63+
*)
64+
# Failed to stop
65+
;;
66+
esac
67+
;;
68+
configtest|testconfig)
69+
test_config
70+
;;
71+
*)
72+
echo "Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest}" >&2
73+
exit 3
74+
;;
75+
esac
76+

cpack/debian/postinst

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
case "${1}" in
6+
configure)
7+
chmod +x /etc/init.d/fluent-bit
8+
;;
9+
10+
abort-upgrade|abort-remove|abort-deconfigure)
11+
12+
;;
13+
14+
*)
15+
echo "postinst called with unknown argument \`${1}'" >&2
16+
exit 1
17+
;;
18+
esac
19+
20+
# Automatically added by dh_installinit/12.10
21+
if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then
22+
if [ -x "/etc/init.d/fluent-bit" ]; then
23+
update-rc.d fluent-bit defaults >/dev/null
24+
if [ -n "$2" ]; then
25+
_dh_action=restart
26+
else
27+
_dh_action=start
28+
fi
29+
invoke-rc.d fluent-bit $_dh_action || exit 1
30+
fi
31+
fi
32+
# End automatically added section
33+
34+
35+
exit 0

cpack/debian/postrm

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
case "${1}" in
6+
remove)
7+
8+
;;
9+
10+
purge|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
11+
12+
;;
13+
14+
*)
15+
echo "postrm called with unknown argument \`${1}'" >&2
16+
exit 1
17+
;;
18+
esac
19+
20+
# Automatically added by dh_installinit/12.10
21+
if [ "$1" = "purge" ] ; then
22+
update-rc.d fluent-bit remove >/dev/null
23+
fi
24+
# End automatically added section
25+
26+
27+
exit 0

cpack/debian/prerm

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
set -e
3+
# Automatically added by dh_installinit/12.10
4+
if [ -x "/etc/init.d/fluent-bit" ] && [ "$1" = remove ]; then
5+
invoke-rc.d fluent-bit stop || exit 1
6+
fi
7+
# End automatically added section

src/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,4 +600,9 @@ if(FLB_BINARY)
600600
COMPONENT binary
601601
DESTINATION ${FLB_INSTALL_CONFDIR})
602602

603+
install(FILES
604+
"${PROJECT_SOURCE_DIR}/conf/fluent-bit"
605+
COMPONENT binary
606+
DESTINATION ${FLB_INSTALL_INITDIR})
607+
603608
endif()

0 commit comments

Comments
 (0)