start
}
+online() {
+ echo -n "Switching $progname to online mode: "
+ killproc bpdyndnsd -USR2
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && success || failure
+ echo
+}
+
+online_webcheck() {
+ echo -n "Switching $progname to online mode with webcheck enabled: "
+ killproc bpdyndnsd -RTMIN
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && success || failure
+ echo
+}
+
+offline() {
+ echo -n "Switching $progname to offline mode: "
+ killproc bpdyndnsd -USR1
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && success || failure
+ echo
+}
##
## determine what we should do:
condrestart)
[ -f /var/lock/subsys/bpdyndnsd ] && restart || :
;;
+ online)
+ online
+ ;;
+ online_webcheck)
+ online_webcheck
+ ;;
+ offline)
+ offline
+ ;;
*)
- echo "Usage: bpdyndnsd {start|stop|status|restart|reload|condrestart}"
+ echo "Usage: bpdyndnsd {start|stop|status|restart|reload|condrestart|online|online_webcheck|offline}"
RETVAL=1
esac
int level = 1;
if ( level <= Loglevel )
{
- log_notice("Caught SIGHUP. Reloading config and switching to online mode...");
+ log_notice("Caught SIGHUP. Reloading config...");
+ }
+}
+
+
+/**
+ * SIGUSR2 caught.
+ */
+void Logger::print_caught_siguser2() const
+{
+ int level = 1;
+ if ( level <= Loglevel )
+ {
+ log_notice("Caught SIGUSR2. Switching to online mode...");
+ }
+}
+
+
+/**
+ * SIGRTMIN caught.
+ */
+void Logger::print_caught_sigrtmin() const
+{
+ int level = 1;
+ if ( level <= Loglevel )
+ {
+ log_notice("Caught SIGRTMIN. Switching to online mode with webcheck enabled...");
}
}
Updater::Ptr updater;
bool is_online = false;
+bool webcheck_enabled = false;
/**
* Checks if a bpdyndnsd process is already running.
/**
- * Signal SIGHUP caught, reloading config and switching to online mode.
+ * Signal SIGHUP caught, reloading config.
* @param param Parameter from the signal interface.
*/
void reload_config(int param)
updater->get_logger()->print_caught_sighup();
if ( updater->reload_config() != 0 )
exit(-1);
+} /*lint !e715 */
+
+
+/**
+ * Signal SIGUSR2 caught, switching to online mode.
+ * @param param Parameter from the signal interface.
+ */
+void switch_to_online(int param)
+{
+ updater->get_logger()->print_caught_siguser2();
is_online = true;
+ webcheck_enabled = false;
+} /*lint !e715 */
+
+
+/**
+ * Signal SIGRTMIN caught, switching to online mode with webcheck enabled.
+ * @param param Parameter from the signal interface.
+ */
+void switch_to_online_webcheck(int param)
+{
+ updater->get_logger()->print_caught_sigrtmin();
+ is_online = true;
+ webcheck_enabled = true;
} /*lint !e715 */
updater->get_logger()->print_error_setting_signal("SIGHUP");
return -1;
}
+ ret_val = signal(SIGUSR2,switch_to_online);
+ if ( ret_val == SIG_ERR )
+ {
+ updater->get_logger()->print_error_setting_signal("SIGUSR2");
+ return -1;
+ }
+ ret_val = signal(SIGRTMIN,switch_to_online_webcheck);
+ if ( ret_val == SIG_ERR )
+ {
+ updater->get_logger()->print_error_setting_signal("SIGRTMIN");
+ return -1;
+ }
return 0;
}
if ( init_daemon_mode(updater->get_config()->get_daemon_mode()) != 0 )
return -1;
- // Should we start in offline mode?
- is_online = !updater->get_config()->get_start_offline();
-
// service processing starts here
do
{
+ // Should we start in offline mode?
+ is_online = !updater->get_config()->get_start_offline();
+
if ( is_online == true )
{
// update all configured services