Skip to content
This repository has been archived by the owner on Nov 14, 2020. It is now read-only.

Commit

Permalink
Added StartLimitBurst to systemd and cleaned up logic for checking
Browse files Browse the repository at this point in the history
daemon status
  • Loading branch information
bchambers committed Jul 10, 2018
1 parent a8731f7 commit 0b4c80c
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion deploy/info.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// General information
/////////////////////////////////////////////////////////////////////////////
$app['basename'] = 'syncthing';
$app['version'] = '1.1.14';
$app['version'] = '1.1.15';
$app['release'] = '1';
$app['vendor'] = 'WikiSuite';
$app['packager'] = 'WikiSuite';
Expand Down
8 changes: 4 additions & 4 deletions deploy/service-check
Original file line number Diff line number Diff line change
Expand Up @@ -72,19 +72,19 @@ use \Exception as Exception;
// Command line options
//--------------------------------------------------------------------

$short_options = '';

// Common
$short_options = 'f'; // Force

$options = getopt($short_options);

$force = isset($options['f']) ? TRUE : FALSE;

// Command line options
//--------------------------------------------------------------------

$syncthing = new Syncthing();

try {
$syncthing->restart_multiuser();
$syncthing->restart_multiuser($force);
} catch (Exception $e) {
echo clearos_exception_message($e) . "\n";
}
Expand Down
5 changes: 5 additions & 0 deletions deploy/upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ if [ -z "$CHECK" ]; then
sed -i "/RewriteCond/d" /usr/clearos/sandbox/etc/httpd/conf.d/syncthing.conf
sed -i "/RewriteRule/d" /usr/clearos/sandbox/etc/httpd/conf.d/syncthing.conf
fi
CHECK=`grep "StartLimitBurst=0" /etc/systemd/system/syncthing@.service`
if [ -z "$CHECK" ]; then
sed -i "/^User=%i$/a StartLimitBurst=0" /etc/systemd/system/syncthing@.service
/usr/bin/systemctl daemon-reload
fi
16 changes: 9 additions & 7 deletions libraries/Syncthing.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ public function set_state($username, $enabled)
$shell = new Shell();
if ($enabled) {
$shell->execute(parent::COMMAND_SYSTEMCTL, "enabled syncthing@$username.service", TRUE, $options);
$shell->execute(parent::COMMAND_SYSTEMCTL, "start syncthing@$username.service", TRUE, $options);
$shell->execute(parent::COMMAND_SYSTEMCTL, "restart syncthing@$username.service", TRUE, $options);
} else {
$shell->execute(parent::COMMAND_SYSTEMCTL, "disabled syncthing@$username.service", TRUE, $options);
$shell->execute(parent::COMMAND_SYSTEMCTL, "stop syncthing@$username.service", TRUE, $options);
Expand Down Expand Up @@ -387,26 +387,28 @@ public function get_lan_ip()

/**
* Restart all daemons.
* @param $force force restart
*
* @throws Engine_Exception
*/

function restart_multiuser()
function restart_multiuser($force = false)
{
clearos_profile(__METHOD__, __LINE__);
$file = new File(self::FILE_RESTART_MULTIUSER);
if (!$file->exists())
if (!$force && !$file->exists())
return;
$users = $this->get_users_config();
foreach ($users as $user => $meta) {
try {
$this->set_state($user, FALSE);
if ($meta['enabled'] !== TRUE)
$this->set_state($user, TRUE);
if ($force || ($meta['status'] && !$meta['enabled']) || (!$meta['status'] && $meta['enabled']))
$this->set_state($user, $meta['enabled']);
} catch (Exception $e) {
clearos_log('syncthing', $user . ":" . clearos_exception_message($e));
}
}
$file->delete();
if ($file->exists())
$file->delete();
}

/**
Expand Down
1 change: 1 addition & 0 deletions packaging/app-syncthing.cron
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*/10 * * * * root /usr/clearos/apps/syncthing/deploy/service-check >/dev/null 2>&1
0 4 * * * root /usr/clearos/apps/syncthing/deploy/service-check -f >/dev/null 2>&1
0 */4 * * * root /usr/clearos/apps/syncthing/deploy/config-check >/dev/null 2>&1
2 changes: 1 addition & 1 deletion packaging/app-syncthing.spec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Name: app-syncthing
Epoch: 1
Version: 1.1.14
Version: 1.1.15
Release: 1%{dist}
Summary: Syncthing
License: GPLv3
Expand Down

0 comments on commit 0b4c80c

Please sign in to comment.