diff --git a/tools/init.d/CMakeLists.init b/tools/init.d/CMakeLists.init index 1428402883b..153d15a2d35 100644 --- a/tools/init.d/CMakeLists.init +++ b/tools/init.d/CMakeLists.init @@ -19,6 +19,7 @@ macro (CREATE_INIT_SCRIPT initname daemonname) add_custom_target(${initname}.target ALL COMMAND sed -e 's,[@]DAEMON[@],${daemonname},g' < ${PROJECT_SOURCE_DIR}/tools/init.d/template > ${CMAKE_CURRENT_BINARY_DIR}/${initname} + COMMAND sed -i 's,[@]CRONFILE[@],${initname}-metrica-yandex,g' ${CMAKE_CURRENT_BINARY_DIR}/${initname} COMMAND chmod a+x ${CMAKE_CURRENT_BINARY_DIR}/${initname} COMMENT "Building ${initname}" ) diff --git a/tools/init.d/template b/tools/init.d/template index 4c2f3b4a410..ac55ae57832 100755 --- a/tools/init.d/template +++ b/tools/init.d/template @@ -15,6 +15,7 @@ PIDDIR=/var/run/$PROGRAM LOGDIR=/var/log/$PROGRAM LOCALSTATEDIR=/var/lock BINDIR=/usr/bin +CRONFILE=/etc/cron.d/@CRONFILE@ [ -x $BINDIR/$PROGRAM ] || exit 0 @@ -91,14 +92,24 @@ restart() start } +enable_cron() +{ + sed -i 's/^#*//' "$CRONFILE" +} + +disable_cron() +{ + sed -i 's/^#*/#/' "$CRONFILE" +} + # See how we were called. EXIT_STATUS=0 case "$1" in start) - start + enable_cron && start ;; stop) - stop + disable_cron && stop ;; status) isrun && echo "$PROGRAM service is running" || echo "$PROGRAM service is stopped"