mirror of
https://github.com/unraid/webgui.git
synced 2026-02-21 17:29:15 -06:00
Merge remote-tracking branch 'upstream/master' into Add-Clone-VM-option-
This commit is contained in:
@@ -621,7 +621,7 @@ Share can *not* be deleted as long as it contains data. Be aware that some data
|
||||
:end
|
||||
|
||||
:share_edit_exclusive_access_help:
|
||||
When set to "Yes" indicates a synmlink directly to a pool has been set up for the share in the /mnt/user tree.
|
||||
When set to "Yes" indicates a symlink directly to a pool has been set up for the share in the /mnt/user tree.
|
||||
|
||||
Refer to [Global Share Settings](Settings/ShareSettings) -> Permit exclusive shares.
|
||||
:end
|
||||
@@ -2003,12 +2003,22 @@ Write mover messages to the syslog file.
|
||||
|
||||
:notifications_display_help:
|
||||
In *Detailed* view all notifications will be displayed on screen as soon as they arrive.<br>
|
||||
Notifications can be acknowledged individually or all in once.
|
||||
Notifications can be acknowledged individually or all at once.
|
||||
|
||||
In *Summarized* view notifications will be counted only and the number of unread notifications is shown in the menu header per category.<br>
|
||||
Click on the counters to either acknowledge or view the unread notifications.
|
||||
:end
|
||||
|
||||
:notifications_display_position_help:
|
||||
Choose the position of where notifications appear on screen in *Detailed* view. Multiple notifications are stacked, bottom-to-top or
|
||||
top-to-bottom depending on the selected placement.
|
||||
:end
|
||||
|
||||
:notifications_auto_close_help:
|
||||
Number of seconds before notifications are automatically closed in *Detailed* view.<br>
|
||||
A value of 0 disables automatic closure.
|
||||
:end
|
||||
|
||||
:notifications_date_format_help:
|
||||
Select the desired date format which is used in the notifications archive. Recommended is YYYY-MM-DD, which makes the date/time column sortable in a sensible way.
|
||||
:end
|
||||
@@ -2017,10 +2027,6 @@ Select the desired date format which is used in the notifications archive. Recom
|
||||
Select the desired time format which is used in the notifications archive. Recommended is 24 hours, which makes the date/time column sortable in a sensible way.
|
||||
:end
|
||||
|
||||
:notifications_display_position_help:
|
||||
Choose the position of where notifications appear on screen. Multiple notifications are stacked, bottom-to-top or top-to-bottom depending on the selected placement.
|
||||
:end
|
||||
|
||||
:notifications_store_flash_help:
|
||||
By default notifications are stored on RAM disk, which will get lost upon system reboot.
|
||||
Notifications may be stored permanently on the flash drive under folder '/boot/config/plugins/dynamix' instead.
|
||||
|
||||
@@ -23,6 +23,9 @@ require_once "$docroot/plugins/dynamix.docker.manager/include/DockerClient.php";
|
||||
$DockerClient = new DockerClient();
|
||||
exec("/etc/rc.d/rc.docker status >/dev/null",$dummy,$DockerStopped);
|
||||
|
||||
exec("ls --indicator-style=none /sys/class/net|awk '/^br[0-9]+$/'",$nics);
|
||||
$bridge = count($nics)>0;
|
||||
|
||||
function strposX($s, $c, $n=1) {
|
||||
$p = 0;
|
||||
while ($n && $p=strpos($s,$c,$p)!==false) {$n--; $p+=strlen($c);}
|
||||
@@ -254,6 +257,16 @@ _(Template Authoring Mode)_:
|
||||
|
||||
:docker_authoring_mode_help:
|
||||
|
||||
<?if ($bridge):?>
|
||||
_(Docker custom network type)_:
|
||||
: <select name="DOCKER_NETWORK_TYPE">
|
||||
<?=mk_option(_var($dockercfg,'DOCKER_NETWORK_TYPE'), '1', _('ipvlan'))?>
|
||||
<?=mk_option(_var($dockercfg,'DOCKER_NETWORK_TYPE'), '', _('macvlan'))?>
|
||||
</select> _(Please read the Help carefully)_. _(Misconfiguration can cause problems)_.
|
||||
|
||||
:docker_custom_network_type_help:
|
||||
|
||||
<?endif;?>
|
||||
_(Host access to custom networks)_:
|
||||
: <select name="DOCKER_ALLOW_ACCESS">
|
||||
<?=mk_option(_var($dockercfg,'DOCKER_ALLOW_ACCESS'), '', _('Disabled'))?>
|
||||
@@ -307,8 +320,8 @@ _(IPv4 custom network on interface)_ <?=$network?> (_(optional)_):
|
||||
<?
|
||||
for ($b=$box; $b<=3; $b++) {
|
||||
switch ($b) {
|
||||
case 1: $step = $size/65536%256; break;
|
||||
case 2: $step = $size/256%256; break;
|
||||
case 1: $step = floor($size/65536)%256; break;
|
||||
case 2: $step = floor($size/256)%256; break;
|
||||
case 3: $step = $size%256; break;
|
||||
}
|
||||
if ($step===0) $step = 256;
|
||||
@@ -452,6 +465,13 @@ _(Docker LOG rotation)_:
|
||||
|
||||
:docker_log_rotation_active_help:
|
||||
|
||||
<?if ($bridge):?>
|
||||
_(Docker custom network type)_:
|
||||
: <?=_var($dockercfg,'DOCKER_NETWORK_TYPE')=='1' ? _('ipvlan') : _('macvlan')?>
|
||||
|
||||
:docker_custom_network_type_help:
|
||||
|
||||
<?endif;?>
|
||||
_(Host access to custom networks)_:
|
||||
: <?=_var($dockercfg,'DOCKER_ALLOW_ACCESS')=='yes' ? _('Enabled') : _('Disabled')?>
|
||||
|
||||
@@ -761,13 +781,13 @@ function changeMask(id,val) {
|
||||
for (var b=1; b<=3; b++) {
|
||||
var cell = id+b;
|
||||
switch (b) {
|
||||
case 1: var step = mask/65536%256; break;
|
||||
case 2: var step = mask/256%256; break;
|
||||
case 1: var step = Math.floor(mask/65536)%256; break;
|
||||
case 2: var step = Math.floor(mask/256)%256; break;
|
||||
case 3: var step = mask%256; break;
|
||||
}
|
||||
if (step==0) step = 256;
|
||||
if ($(cell).length==0) continue;
|
||||
var max = $(cell+' option').size();
|
||||
var max = $(cell+' option').length;
|
||||
for (var i=0; i < max; i++) if (i%step==0) $(cell+' option:eq('+i+')').removeClass('hide'); else $(cell+' option:eq('+i+')').addClass('hide');
|
||||
if ($(cell+' option:selected').val()%step!=0) $(cell+' option:selected').removeAttr('selected');
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ $DockerClient = new DockerClient();
|
||||
$DockerUpdate = new DockerUpdate();
|
||||
$DockerTemplates = new DockerTemplates();
|
||||
|
||||
$start = array_map(function($row){return strtok($row,' ');},@file('/var/lib/docker/unraid-autostart',FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES) ?: []);
|
||||
$custom = DockerUtil::custom();
|
||||
$subnet = DockerUtil::network($custom);
|
||||
$cpus = DockerUtil::cpus();
|
||||
@@ -30,6 +31,7 @@ $old = $DockerClient->getImageID($repository);
|
||||
|
||||
removeContainer($name,false,false);
|
||||
execCommand(str_replace('/docker create ','/docker run -d ',$cmd),false);
|
||||
if (!in_array($name,$start)) stopContainer($name,false,false);
|
||||
$DockerClient->flushCaches();
|
||||
$new = $DockerClient->getImageID($repository);
|
||||
if ($old && $old != $new) removeImage($old,false);
|
||||
|
||||
@@ -121,6 +121,7 @@ case 'domain-start-consoleRV':
|
||||
$vvarray[] = "type=$protocol\n";
|
||||
$vvarray[] = "host="._var($_SERVER,'HTTP_HOST')."\n" ;
|
||||
$vvarray[] = "port=$port\n" ;
|
||||
$vvarray[] = "delete-this-file=1\n" ;
|
||||
if (!is_dir("/mnt/user/system/remoteviewer")) mkdir("/mnt/user/system/remoteviewer") ;
|
||||
$vvfile = "/mnt/user/system/remoteviewer/rv"._var($_SERVER,'HTTP_HOST').".$port.vv" ;
|
||||
file_put_contents($vvfile,$vvarray) ;
|
||||
@@ -139,6 +140,7 @@ case 'domain-consoleRV':
|
||||
$vvarray[] = "type=$protocol\n";
|
||||
$vvarray[] = "host="._var($_SERVER,'HTTP_HOST')."\n" ;
|
||||
$vvarray[] = "port=$port\n" ;
|
||||
$vvarray[] = "delete-this-file=1\n" ;
|
||||
if (!is_dir("/mnt/user/system/remoteviewer")) mkdir("/mnt/user/system/remoteviewer") ;
|
||||
$vvfile = "/mnt/user/system/remoteviewer/rv"._var($_SERVER,'HTTP_HOST').".$port.vv" ;
|
||||
file_put_contents($vvfile,$vvarray) ;
|
||||
|
||||
@@ -668,32 +668,27 @@
|
||||
$netmodel = $nic['model'] ?: 'virtio-net';
|
||||
|
||||
$net_res =$this->libvirt_get_net_res($this->conn, $nic['network']);
|
||||
$vhost = file_exists("/boot/config/network.cfg") && exec("grep -Po '^BRNICS\[0\]=\"\K[^\"]+' /boot/config/network.cfg")=='';
|
||||
if ($vhost) {
|
||||
exec("ip -br a|grep -Po '^vhost[0-9][^@]*'",$br);
|
||||
} else {
|
||||
exec("brctl show | cut -f1| awk NF | sed -n '1!p'", $br);
|
||||
}
|
||||
exec("ls --indicator-style=none /sys/class/net|grep -Po '^((vir)?br|vhost)[0-9]+(\.[0-9]+)?'",$br);
|
||||
if ($nic["boot"] != NULL) $nicboot = "<boot order='".$nic["boot"]."'/>" ; else $nicboot = "" ;
|
||||
if($net_res) {
|
||||
if ($net_res) {
|
||||
$netstr .= "<interface type='network'>
|
||||
<mac address='{$nic['mac']}'/>
|
||||
<source network='" . htmlspecialchars($nic['network'], ENT_QUOTES | ENT_XML1) . "'/>
|
||||
<model type='$netmodel'/>
|
||||
$nicboot
|
||||
</interface>";
|
||||
} elseif(in_array($nic['network'], $br)) {
|
||||
if ($vhost) {
|
||||
$netstr .= "<interface type='direct'>
|
||||
} elseif (in_array($nic['network'], $br)) {
|
||||
if (preg_match('/^(vir)?br/',$nic['network'])) {
|
||||
$netstr .= "<interface type='bridge'>
|
||||
<mac address='{$nic['mac']}'/>
|
||||
<source dev='" . htmlspecialchars($nic['network'], ENT_QUOTES | ENT_XML1) . "' mode='bridge'/>
|
||||
<source bridge='" . htmlspecialchars($nic['network'], ENT_QUOTES | ENT_XML1) . "'/>
|
||||
<model type='$netmodel'/>
|
||||
$nicboot
|
||||
</interface>";
|
||||
} else {
|
||||
$netstr .= "<interface type='bridge'>
|
||||
$netstr .= "<interface type='direct' trustGuestRxFilters='yes'>
|
||||
<mac address='{$nic['mac']}'/>
|
||||
<source bridge='" . htmlspecialchars($nic['network'], ENT_QUOTES | ENT_XML1) . "'/>
|
||||
<source dev='" . htmlspecialchars($nic['network'], ENT_QUOTES | ENT_XML1) . "' mode='bridge'/>
|
||||
<model type='$netmodel'/>
|
||||
$nicboot
|
||||
</interface>";
|
||||
|
||||
@@ -1066,11 +1066,7 @@ private static $encoding = 'UTF-8';
|
||||
function getValidNetworks() {
|
||||
global $lv;
|
||||
$arrValidNetworks = [];
|
||||
if (file_exists("/boot/config/network.cfg") && exec("grep -Po '^BRNICS\[0\]=\"\K[^\"]+' /boot/config/network.cfg")=='') {
|
||||
exec("ip -br a|grep -Po '^(virbr|vhost)[0-9][^@ ]*'",$arrBridges);
|
||||
} else {
|
||||
exec("brctl show|grep -Po '^(vir)?br\d\S*'", $arrBridges);
|
||||
}
|
||||
exec("ls --indicator-style=none /sys/class/net|grep -Po '^((vir)?br|vhost)[0-9]+(\.[0-9]+)?'",$arrBridges);
|
||||
if (!is_array($arrBridges)) {
|
||||
$arrBridges = [];
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ $disabled = $notify['system'] ? '' : 'disabled';
|
||||
?>
|
||||
<style>
|
||||
select.a{min-width:220px}
|
||||
input.a{width:220px}
|
||||
span.a{display:inline-block;width:220px;font-style:italic}
|
||||
</style>
|
||||
<script>
|
||||
@@ -123,6 +124,22 @@ _(Notifications display)_:
|
||||
|
||||
:notifications_display_help:
|
||||
|
||||
_(Display position)_:
|
||||
: <select name="position" class="a">
|
||||
<?=mk_option($notify['position'], "top-left", _("top-left"))?>
|
||||
<?=mk_option($notify['position'], "top-right", _("top-right"))?>
|
||||
<?=mk_option($notify['position'], "bottom-left", _("bottom-left"))?>
|
||||
<?=mk_option($notify['position'], "bottom-right", _("bottom-right"))?>
|
||||
<?=mk_option($notify['position'], "center", _("center"))?>
|
||||
</select>
|
||||
|
||||
:notifications_display_position_help:
|
||||
|
||||
_(Auto-close)_ (_(seconds)_):
|
||||
: <input type="number" name="life" class="a" min="0" max="60" value="<?=$notify['life']?>"> _(a value of zero means no automatic closure)_
|
||||
|
||||
:notifications_auto_close_help:
|
||||
|
||||
_(Date format)_:
|
||||
: <select name="date" class="a">
|
||||
<?=mk_option($notify['date'], "d-m-Y", _("DD-MM-YYYY"))?>
|
||||
@@ -140,17 +157,6 @@ _(Time format)_:
|
||||
|
||||
:notifications_time_format_help:
|
||||
|
||||
_(Display position)_:
|
||||
: <select name="position" class="a">
|
||||
<?=mk_option($notify['position'], "top-left", _("top-left"))?>
|
||||
<?=mk_option($notify['position'], "top-right", _("top-right"))?>
|
||||
<?=mk_option($notify['position'], "bottom-left", _("bottom-left"))?>
|
||||
<?=mk_option($notify['position'], "bottom-right", _("bottom-right"))?>
|
||||
<?=mk_option($notify['position'], "center", _("center"))?>
|
||||
</select>
|
||||
|
||||
:notifications_display_position_help:
|
||||
|
||||
_(Store notifications to flash)_:
|
||||
: <select name="path" class="a">
|
||||
<?=mk_option($notify['path'], "/tmp/notifications", _("No"))?>
|
||||
|
||||
@@ -41,6 +41,7 @@ cron=""
|
||||
write="NOCORRECT"
|
||||
[notify]
|
||||
display="0"
|
||||
life="5"
|
||||
date="d-m-Y"
|
||||
time="H:i"
|
||||
position="top-right"
|
||||
|
||||
@@ -590,7 +590,11 @@ $(function() {
|
||||
$.jGrowl.defaults.theme = '';
|
||||
$.jGrowl.defaults.themeState = '';
|
||||
$.jGrowl.defaults.pool = 10;
|
||||
$.jGrowl.defaults.life = 3000;
|
||||
<?if ($notify['life'] > 0):?>
|
||||
$.jGrowl.defaults.life = <?=$notify['life']*1000?>;
|
||||
<?else:?>
|
||||
$.jGrowl.defaults.sticky = true;
|
||||
<?endif;?>
|
||||
Shadowbox.setup('a.sb-enable', {modal:true});
|
||||
// add any pre-existing reboot notices
|
||||
$.post('/webGui/include/Report.php',{cmd:'notice'},function(notices){
|
||||
@@ -868,7 +872,7 @@ defaultPage.on('message', function(msg,meta) {
|
||||
beforeOpen: function(e,m,o){if ($('div.jGrowl-notification').hasClass(notify.file)) return(false);},
|
||||
afterOpen: function(e,m,o){if (notify.link) $(e).css('cursor','pointer');},
|
||||
click: function(e,m,o){if (notify.link) location.replace(notify.link);},
|
||||
close: function(e,m,o){$.post('/webGui/include/Notify.php',{cmd:'hide',file:"<?=$notify['path'].'/unread/'?>"+notify.file,csrf_token:csrf_token});}
|
||||
close: function(e,m,o){$.post('/webGui/include/Notify.php',{cmd:'hide',file:"<?=$notify['path'].'/unread/'?>"+notify.file,csrf_token:csrf_token}<?if ($notify['life']==0):?>,function(){$.post('/webGui/include/Notify.php',{cmd:'archive',file:notify.file,csrf_token:csrf_token});}<?endif;?>);}
|
||||
});
|
||||
}
|
||||
<?endif;?>
|
||||
|
||||
@@ -924,6 +924,9 @@ class MarkdownExtra extends \Michelf\Markdown {
|
||||
$title = $this->encodeAttribute($title);
|
||||
$result .= " title=\"$title\"";
|
||||
}
|
||||
// limetech - if URL starts with "http" then open in new tab/window
|
||||
if (str_starts_with($url, "http"))
|
||||
$result .= " target='_blank'";
|
||||
$result .= $attr;
|
||||
|
||||
$link_text = $this->runSpanGamut($link_text);
|
||||
|
||||
@@ -34,7 +34,7 @@ default:
|
||||
$gateway = $cell[2];
|
||||
if ($route=='default') $gateway .= " via {$cell[4]}";
|
||||
$metric = '0';
|
||||
for ($i=5; $i<count($cell); $i++) if ($cell[$i]=='metric') {$metric = $cell[$i+1]; break;}
|
||||
for ($i=3; $i<count($cell); $i++) if ($cell[$i]=='metric') {$metric = $cell[$i+1]; break;}
|
||||
echo "<tr><td>IPv4</td><td>$route</td><td>$gateway</td><td>$metric</td><td style='text-align:center'><a href='#' onclick='deleteRoute(\"$gateway\",\"$route\",\"$metric\");return false'><i class='fa fa-trash-o'></i></a></td></tr>";
|
||||
}
|
||||
if ($ipv6) echo "<tr class='tr_last'><td colspan='5'> </td></tr>";
|
||||
@@ -44,7 +44,7 @@ default:
|
||||
$gateway = $route=='anycast' ? $cell[3] : $cell[2];
|
||||
if ($route=='default') $gateway .= " via {$cell[4]}";
|
||||
$metric = '1';
|
||||
for ($i=5; $i<count($cell); $i++) if ($cell[$i]=='metric') {$metric = $cell[$i+1]; break;}
|
||||
for ($i=3; $i<count($cell); $i++) if ($cell[$i]=='metric') {$metric = $cell[$i+1]; break;}
|
||||
echo "<tr><td>IPv6</td><td>$route</td><td>$gateway</td><td>$metric</td><td style='text-align:center'><a href='#' onclick='deleteRoute(\"$gateway\",\"$route\",\"$metric\");return false'><i class='fa fa-trash-o'></i></a></td></tr>";
|
||||
}
|
||||
echo "<tr class='tr_last'><td colspan='5'> </td></tr>";
|
||||
|
||||
@@ -42,7 +42,7 @@ switch ($_POST['table']) {
|
||||
case 't1load':
|
||||
$list = file_get_contents($sysdrvfile) ;
|
||||
$arrModules = json_decode($list,TRUE) ;
|
||||
var $init = false;
|
||||
$init = false;
|
||||
if (is_file($sysdrvinit)) $init = file_get_contents($sysdrvinit);
|
||||
$html = "<thead><tr><th><b>"._("Driver")."</th><th><b>"._("Description")."</th><th data-value='System|Inuse|Custom|Disabled|\"Kernel - Inuse\"'><b>"._("State")."</th><th><b>"._("Type")."</th><th><b>"._("Modprobe.d config file")."</th></tr></thead>";
|
||||
$html .= "<tbody>" ;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/php -q
|
||||
<?PHP
|
||||
/* Copyright 2005-2018, Lime Technology
|
||||
* Copyright 2012-2018, Bergware International.
|
||||
/* Copyright 2005-2023, Lime Technology
|
||||
* Copyright 2012-2023, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
@@ -17,6 +17,21 @@ $run = $set != 'none';
|
||||
$ini = parse_ini_file('/var/local/emhttp/network.ini',true); ksort($ini,SORT_NATURAL);
|
||||
$cfg = '/boot/config/network.cfg';
|
||||
|
||||
function update_wireguard($ifname) {
|
||||
if (!in_array($ifname,['br0','bond0','eth0'])) return;
|
||||
$nic = file_exists('/sys/class/net/br0') ? 'br0' : (file_exists('/sys/class/net/bond0') ? 'bond0' : 'eth0');
|
||||
exec("wg show interfaces|tr ' ' '\n'",$active);
|
||||
foreach (glob("/etc/wireguard/*.conf",GLOB_NOSORT) as $wg) {
|
||||
$vtun = basename($wg,'.conf');
|
||||
// interface has changed?
|
||||
if (exec("grep -Pom1 ' dev $nic ' $wg")=='') {
|
||||
exec("logger -t netconfig 'updated wireguard $vtun configuration'");
|
||||
exec("sed -ri 's/ dev (br0|bond0|eth0) / dev $nic /' $wg");
|
||||
}
|
||||
// restart active wireguard tunnels
|
||||
if (in_array($vtun,$active)) exec("wg-quick down $vtun; sleep 1; wg-quick up $vtun");
|
||||
}
|
||||
}
|
||||
function ifname($name) {
|
||||
global $old;
|
||||
if (!$name) return;
|
||||
@@ -113,6 +128,7 @@ file_put_contents($cfg,implode("\r\n",$new)."\r\n");
|
||||
if ($run) {
|
||||
exec("/etc/rc.d/rc.inet1 {$ifname}_start >/dev/null 2>&1");
|
||||
exec("/usr/local/sbin/create_network_ini $ifname >/dev/null 2>&1 &");
|
||||
update_wireguard($ifname);
|
||||
}
|
||||
exit(0);
|
||||
?>
|
||||
|
||||
@@ -62,7 +62,7 @@ div.title span.right{font-size:1.4rem;padding-top:2px;padding-right:10px;float:r
|
||||
div.title span img{padding-right:4px}
|
||||
div.title.shift{margin-top:-30px}
|
||||
#menu{position:absolute;top:90px;left:0;right:0;display:grid;grid-template-columns:auto max-content;z-index:101}
|
||||
.nav-tile{height:4rem;line-height:4rem;padding:0;margin:0;font-size:1.2rem;letter-spacing:1.8px;background-color:#f2f2f2;white-space:nowrap;overflow-x:scroll;overflow-y:hidden;scrollbar-width:thin}
|
||||
.nav-tile{height:4rem;line-height:4rem;padding:0;margin:0;font-size:1.2rem;letter-spacing:1.8px;background-color:#f2f2f2;white-space:nowrap;overflow-x:auto;overflow-y:hidden;scrollbar-width:thin}
|
||||
.nav-tile::-webkit-scrollbar{height:8px}
|
||||
.nav-tile.right{text-align:right}
|
||||
.nav-item,.nav-user{position:relative;display:inline-block;text-align:center;margin:0}
|
||||
|
||||
@@ -62,7 +62,7 @@ div.title span.right{font-size:1.4rem;padding-top:2px;padding-right:10px;float:r
|
||||
div.title span img{padding-right:4px}
|
||||
div.title.shift{margin-top:-30px}
|
||||
#menu{position:absolute;top:90px;left:0;right:0;display:grid;grid-template-columns:auto max-content;z-index:101}
|
||||
.nav-tile{height:4rem;line-height:4rem;padding:0;margin:0;font-size:1.2rem;letter-spacing:1.8px;background-color:#1c1b1b;white-space:nowrap;overflow-x:scroll;overflow-y:hidden;scrollbar-width:thin}
|
||||
.nav-tile{height:4rem;line-height:4rem;padding:0;margin:0;font-size:1.2rem;letter-spacing:1.8px;background-color:#1c1b1b;white-space:nowrap;overflow-x:auto;overflow-y:hidden;scrollbar-width:thin}
|
||||
.nav-tile::-webkit-scrollbar{height:8px}
|
||||
.nav-tile.right{text-align:right}
|
||||
.nav-item,.nav-user{position:relative;display:inline-block;text-align:center;margin:0}
|
||||
|
||||
1
etc/rc.d/rc.0
Symbolic link
1
etc/rc.d/rc.0
Symbolic link
@@ -0,0 +1 @@
|
||||
rc.6
|
||||
60
etc/rc.d/rc.4
Executable file
60
etc/rc.d/rc.4
Executable file
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# rc.4 This file is executed by init(8) when the system is being
|
||||
# initialized for run level 4 (XDM)
|
||||
#
|
||||
# Version: @(#)/etc/rc.d/rc.4 2.00 02/17/93
|
||||
#
|
||||
# Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
|
||||
# At least 47% rewritten by: Patrick J. Volkerding <volkerdi@slackware.com>
|
||||
#
|
||||
|
||||
# Tell the viewers what's going to happen...
|
||||
echo "Starting up X11 session manager..."
|
||||
|
||||
# If you'd like to start something different or in a different order than
|
||||
# the options below, create your own startup script /etc/rc.d/rc.4.local
|
||||
# and make it executable and it will be used instead:
|
||||
if [ -x /etc/rc.d/rc.4.local ]; then
|
||||
exec /bin/bash /etc/rc.d/rc.4.local
|
||||
fi
|
||||
|
||||
# Try to use GNOME's gdm session manager. This comes first because if
|
||||
# gdm is on the machine then the user probably installed it and wants
|
||||
# to use it by default:
|
||||
if [ -x /usr/bin/gdm ]; then
|
||||
exec /usr/bin/gdm
|
||||
fi
|
||||
|
||||
# Someone thought that gdm looked prettier in /usr/sbin,
|
||||
# so look there, too:
|
||||
if [ -x /usr/sbin/gdm ]; then
|
||||
exec /usr/sbin/gdm
|
||||
fi
|
||||
|
||||
# Not there? OK, try to use KDE's kdm session manager:
|
||||
if [ -x /opt/kde/bin/kdm ]; then
|
||||
exec /opt/kde/bin/kdm -nodaemon
|
||||
elif [ -x /usr/bin/kdm ]; then
|
||||
exec /usr/bin/kdm -nodaemon
|
||||
fi
|
||||
|
||||
# Look for SDDM as well:
|
||||
if [ -x /usr/bin/sddm ]; then
|
||||
exec /usr/bin/sddm
|
||||
fi
|
||||
|
||||
# If all you have is XDM, I guess it will have to do:
|
||||
if [ -x /usr/bin/xdm ]; then
|
||||
exec /usr/bin/xdm -nodaemon
|
||||
elif [ -x /usr/X11R6/bin/xdm ]; then
|
||||
exec /usr/X11R6/bin/xdm -nodaemon
|
||||
fi
|
||||
|
||||
# error
|
||||
echo
|
||||
echo "Hey, you don't have SDDM, KDM, GDM, or XDM. Can't use runlevel 4 without"
|
||||
echo "one of those installed."
|
||||
sleep 30
|
||||
|
||||
# All done.
|
||||
9
etc/rc.d/rc.4.local
Executable file
9
etc/rc.d/rc.4.local
Executable file
@@ -0,0 +1,9 @@
|
||||
#! /bin/sh
|
||||
#
|
||||
# rc.4.local This file is executed by rc.4
|
||||
#
|
||||
|
||||
# Try to use SLiM login manager:
|
||||
if [ -x /usr/bin/slim ]; then
|
||||
exec /usr/bin/slim
|
||||
fi
|
||||
278
etc/rc.d/rc.6
Executable file
278
etc/rc.d/rc.6
Executable file
@@ -0,0 +1,278 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# rc.6 This file is executed by init when it goes into runlevel
|
||||
# 0 (halt) or runlevel 6 (reboot). It kills all processes,
|
||||
# unmounts file systems and then either halts or reboots.
|
||||
#
|
||||
# Version: @(#)/etc/rc.d/rc.6 15.0 Wed Nov 10 21:19:42 UTC 2021
|
||||
#
|
||||
# Author: Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org>
|
||||
# Modified by: Patrick J. Volkerding, <volkerdi@slackware.com>
|
||||
#
|
||||
# limetech - modified for Unraid OS
|
||||
|
||||
# Set the path.
|
||||
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
|
||||
|
||||
# If there are SystemV init scripts for this runlevel, run them.
|
||||
if [ -x /etc/rc.d/rc.sysvinit ]; then
|
||||
/etc/rc.d/rc.sysvinit
|
||||
fi
|
||||
|
||||
# Set linefeed mode to avoid staircase effect.
|
||||
/bin/stty onlcr
|
||||
|
||||
echo "Running shutdown script $0:"
|
||||
|
||||
# Find out how we were called.
|
||||
case "$0" in
|
||||
*0)
|
||||
shutdown_command="halt"
|
||||
;;
|
||||
*6)
|
||||
shutdown_command=reboot
|
||||
;;
|
||||
*)
|
||||
echo "$0: call me as \"rc.0\" or \"rc.6\" please!"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Restart init. This prevents init from hanging on to file handles for removed
|
||||
# glibc shared libraries in the case that those were upgraded or reinstalled.
|
||||
/sbin/telinit u
|
||||
|
||||
# Save the system time to the hardware clock using hwclock --systohc.
|
||||
# This will also create or update the timestamps in /etc/adjtime.
|
||||
if [ -x /sbin/hwclock ]; then
|
||||
# Check for a broken motherboard RTC clock (where ioports for rtc are
|
||||
# unknown) to prevent hwclock causing a hang:
|
||||
if ! grep -q " : rtc" /proc/ioports ; then
|
||||
CLOCK_OPT="--directisa"
|
||||
fi
|
||||
if [ /etc/adjtime -nt /etc/hardwareclock ]; then
|
||||
if grep -q "^LOCAL" /etc/adjtime ; then
|
||||
echo "Saving system time to the hardware clock (localtime)."
|
||||
else
|
||||
echo "Saving system time to the hardware clock (UTC)."
|
||||
fi
|
||||
/sbin/hwclock $CLOCK_OPT --systohc
|
||||
elif grep -q "^UTC" /etc/hardwareclock 2> /dev/null ; then
|
||||
echo "Saving system time to the hardware clock (UTC)."
|
||||
if [ ! -r /etc/adjtime ]; then
|
||||
echo "Creating system time correction file /etc/adjtime."
|
||||
fi
|
||||
/sbin/hwclock $CLOCK_OPT --utc --systohc
|
||||
else
|
||||
echo "Saving system time to the hardware clock (localtime)."
|
||||
if [ ! -r /etc/adjtime ]; then
|
||||
echo "Creating system time correction file /etc/adjtime."
|
||||
fi
|
||||
/sbin/hwclock $CLOCK_OPT --localtime --systohc
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run any local shutdown scripts:
|
||||
if [ -x /etc/rc.d/rc.local_shutdown ]; then
|
||||
/etc/rc.d/rc.local_shutdown stop
|
||||
fi
|
||||
|
||||
# Stop mcelog
|
||||
if [ -x /etc/rc.d/rc.mcelog ]; then
|
||||
/etc/rc.d/rc.mcelog stop
|
||||
fi
|
||||
|
||||
# Stop the Samba server:
|
||||
if [ -x /etc/rc.d/rc.samba ]; then
|
||||
/etc/rc.d/rc.samba stop
|
||||
fi
|
||||
|
||||
# Stop avahi:
|
||||
if [ -x /etc/rc.d/rc.avahidaemon ]; then
|
||||
/etc/rc.d/rc.avahidaemon stop
|
||||
/etc/rc.d/rc.avahidnsconfd stop
|
||||
fi
|
||||
|
||||
# Shut down WireGuard
|
||||
if [ -x /etc/rc.d/rc.wireguard ]; then
|
||||
/etc/rc.d/rc.wireguard stop
|
||||
fi
|
||||
|
||||
# Shut down OpenLDAP:
|
||||
if [ -x /etc/rc.d/rc.openldap ]; then
|
||||
/etc/rc.d/rc.openldap stop
|
||||
fi
|
||||
|
||||
# Shut down the SASL authentication daemon:
|
||||
if [ -x /etc/rc.d/rc.saslauthd ]; then
|
||||
/etc/rc.d/rc.saslauthd stop
|
||||
fi
|
||||
|
||||
# Stop the MySQL database:
|
||||
if [ -x /etc/rc.d/rc.mysqld -a -r /var/run/mysql/mysql.pid ]; then
|
||||
/etc/rc.d/rc.mysqld stop
|
||||
fi
|
||||
|
||||
# Shut down the NFS server:
|
||||
if [ -x /etc/rc.d/rc.nfsd ]; then
|
||||
/etc/rc.d/rc.nfsd stop
|
||||
fi
|
||||
|
||||
# Shut down the SSH server:
|
||||
if [ -x /etc/rc.d/rc.sshd ]; then
|
||||
/etc/rc.d/rc.sshd stop
|
||||
fi
|
||||
|
||||
# Stop the Network Time Protocol daemon:
|
||||
if [ -x /etc/rc.d/rc.ntpd ]; then
|
||||
/etc/rc.d/rc.ntpd stop
|
||||
fi
|
||||
|
||||
# Kill any processes (typically gam) that would otherwise prevent
|
||||
# unmounting NFS volumes:
|
||||
unset FUSER_DELAY
|
||||
for dir in $(/bin/mount | grep -e 'type nfs ' -e 'type nfs4 ' | sed -e 's|.* on ||g' | cut -d ' ' -f 1) ; do
|
||||
echo "Killing processes holding NFS mount $dir open..."
|
||||
# Background this to prevent fuser from also blocking shutdown:
|
||||
/usr/bin/fuser -k -M -m "$dir" &
|
||||
FUSER_DELAY=5
|
||||
done
|
||||
# If fuser was run, let it have some delay:
|
||||
if [ ! -z "$FUSER_DELAY" ]; then
|
||||
sleep $FUSER_DELAY
|
||||
fi
|
||||
|
||||
# Unmount any NFS, SMB, or CIFS filesystems:
|
||||
echo "Unmounting remote filesystems:"
|
||||
/bin/umount -v -a -l -f -r -t nfs,nfs4,smbfs,cifs | tr -d ' ' | grep successfully | sed "s/:successfullyunmounted/ has been successfully unmounted./g"
|
||||
# Update PATH hashes:
|
||||
hash -r
|
||||
|
||||
# Stop D-Bus:
|
||||
if [ -x /etc/rc.d/rc.messagebus ]; then
|
||||
/etc/rc.d/rc.messagebus stop
|
||||
fi
|
||||
|
||||
# Bring down the networking system, but first make sure that this
|
||||
# isn't a diskless client with the / partition mounted via NFS:
|
||||
if ! /bin/mount | /bin/grep -q -e 'on / type nfs' -e 'on / type nfs4' ; then
|
||||
if [ -x /etc/rc.d/rc.inet1 ]; then
|
||||
/etc/rc.d/rc.inet1 stop
|
||||
fi
|
||||
fi
|
||||
|
||||
# In case dhcpcd might have been manually started on the command line,
|
||||
# look for the .pid file, and shut dhcpcd down if it's found:
|
||||
if /bin/ls /etc/dhcpc/*.pid 1> /dev/null 2> /dev/null ; then
|
||||
/sbin/dhcpcd -k 1> /dev/null 2> /dev/null
|
||||
# A little time for /etc/resolv.conf and/or other files to
|
||||
# restore themselves.
|
||||
sleep 2
|
||||
fi
|
||||
|
||||
# Turn off process accounting:
|
||||
if [ -x /sbin/accton -a -r /var/log/pacct ]; then
|
||||
/sbin/accton off
|
||||
fi
|
||||
|
||||
# Terminate acpid before syslog:
|
||||
if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid ]; then # quit
|
||||
/etc/rc.d/rc.acpid stop
|
||||
fi
|
||||
|
||||
# Stop udev:
|
||||
if [ -x /etc/rc.d/rc.udev ]; then
|
||||
/etc/rc.d/rc.udev force-stop
|
||||
fi
|
||||
|
||||
# Kill all remaining processes.
|
||||
OMITPIDS="$(for p in $(pgrep mdmon); do echo -o $p; done)" # Don't kill mdmon
|
||||
if [ ! "$1" = "fast" ]; then
|
||||
echo "Sending all processes the SIGTERM signal."
|
||||
/sbin/killall5 -15 $OMITPIDS
|
||||
/bin/sleep 5
|
||||
echo "Sending all processes the SIGKILL signal."
|
||||
/sbin/killall5 -9 $OMITPIDS
|
||||
fi
|
||||
|
||||
# limetech - let's keep this on the USB flash
|
||||
# Carry a random seed between reboots.
|
||||
/usr/sbin/seedrng
|
||||
cp /var/lib/seedrng/seed.credit /boot/config/random-seed 2>/dev/null
|
||||
|
||||
# Before unmounting file systems write a reboot or halt record to wtmp.
|
||||
$shutdown_command -w
|
||||
|
||||
# Turn off swap:
|
||||
if [ ! "$(cat /proc/swaps | wc -l)" = "1" ]; then
|
||||
echo "Turning off swap."
|
||||
/sbin/swapoff -a
|
||||
/bin/sync
|
||||
fi
|
||||
|
||||
# Unmount local file systems:
|
||||
# limetech - but not /, /lib, /usr or /boot (yet)
|
||||
echo "Unmounting local file systems:"
|
||||
EXCLUDE_TYPES=("proc" "sysfs" "tmpfs" "devtmpfs" "devpts" "nfsd")
|
||||
EXCLUDE_PATHS=("/" "/lib" "/usr" "/boot")
|
||||
MOUNTS=$(cat /proc/mounts)
|
||||
while IFS= read -r line; do
|
||||
mount_type=$(echo "$line" | awk '{print $3}')
|
||||
mount_path=$(echo "$line" | awk '{print $2}')
|
||||
[[ " ${EXCLUDE_TYPES[@]} " =~ " ${mount_type} " ]] && continue
|
||||
[[ " ${EXCLUDE_PATHS[@]} " =~ " ${mount_path} " ]] && continue
|
||||
/sbin/umount -v "$mount_path"
|
||||
done <<< "$MOUNTS"
|
||||
|
||||
# limetech - shut down the unraid driver if started
|
||||
if /bin/grep -qs 'mdState=STARTED' /proc/mdstat ; then
|
||||
echo "Stopping md/unraid driver:"
|
||||
echo "stop" > /proc/mdcmd
|
||||
if /bin/grep -qs 'mdState=STOPPED' /proc/mdstat ; then
|
||||
echo "Clean shutdown"
|
||||
/bin/rm -f /boot/config/forcesync
|
||||
else
|
||||
echo "Unclean shutdown - Cannot stop md/unraid driver"
|
||||
fi
|
||||
fi
|
||||
|
||||
# This never hurts:
|
||||
/bin/sync
|
||||
|
||||
# now remount /boot read-only
|
||||
echo "Remounting /boot read-only:"
|
||||
/sbin/mount -v -o remount,ro /boot
|
||||
|
||||
echo "Remounting root filesystem read-only:"
|
||||
/bin/mount -v -n -o remount,ro /
|
||||
|
||||
# sleep 3 fixes problems with some hard drives that don't
|
||||
# otherwise finish syncing before reboot or poweroff
|
||||
/bin/sleep 3
|
||||
|
||||
# This is to ensure all processes have completed on SMP machines:
|
||||
wait
|
||||
|
||||
if [ -x /sbin/genpowerd ]; then
|
||||
# See if this is a powerfail situation:
|
||||
if grep -E -q "FAIL|SCRAM" /etc/upsstatus 2> /dev/null ; then
|
||||
# Signal UPS to shut off the inverter:
|
||||
/sbin/genpowerd -k
|
||||
if [ ! $? = 0 ]; then
|
||||
echo
|
||||
echo "There was an error signaling the UPS."
|
||||
echo "Perhaps you need to edit /etc/genpowerd.conf to configure"
|
||||
echo "the serial line and UPS type."
|
||||
# Wasting 15 seconds of precious power:
|
||||
/bin/sleep 15
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Now halt (poweroff with APM or ACPI enabled kernels) or reboot.
|
||||
if [ "$shutdown_command" = "reboot" ]; then
|
||||
echo "Rebooting."
|
||||
/sbin/reboot
|
||||
else
|
||||
/sbin/poweroff
|
||||
fi
|
||||
126
etc/rc.d/rc.K
Executable file
126
etc/rc.d/rc.K
Executable file
@@ -0,0 +1,126 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# rc.K This file is executed by init when it goes into runlevel
|
||||
# 1, which is the administrative state. It kills all
|
||||
# daemons and then puts the system into single user mode.
|
||||
# Note that the file systems are kept mounted.
|
||||
#
|
||||
# Version: @(#)/etc/rc.d/rc.K 3.1415 Sat Jan 13 13:37:26 PST 2001
|
||||
#
|
||||
# Author: Miquel van Smoorenburg <miquels@drinkel.nl.mugnet.org>
|
||||
# Modified by: Patrick J. Volkerding <volkerdi@slackware.com>
|
||||
#
|
||||
|
||||
# Set the path.
|
||||
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
|
||||
|
||||
# Load a custom screen font if the user has an rc.font script.
|
||||
if [ -x /etc/rc.d/rc.font ]; then
|
||||
/etc/rc.d/rc.font
|
||||
fi
|
||||
|
||||
# Load any needed keyboard mappings:
|
||||
if [ -x /etc/rc.d/rc.keymap ]; then
|
||||
/etc/rc.d/rc.keymap
|
||||
fi
|
||||
|
||||
# If there are SystemV init scripts for this runlevel, run them.
|
||||
if [ -x /etc/rc.d/rc.sysvinit ]; then
|
||||
/etc/rc.d/rc.sysvinit
|
||||
fi
|
||||
|
||||
# Try to turn off quota:
|
||||
if grep -q quota /etc/fstab ; then
|
||||
if [ -x /sbin/quotaoff ]; then
|
||||
echo "Turning off filesystem quotas."
|
||||
/sbin/quotaoff -a
|
||||
fi
|
||||
fi
|
||||
|
||||
# Try to turn off accounting:
|
||||
if [ -x /sbin/accton -a -r /var/log/pacct ]; then
|
||||
/sbin/accton off
|
||||
fi
|
||||
|
||||
# Run any local shutdown scripts:
|
||||
if [ -x /etc/rc.d/rc.local_shutdown ]; then
|
||||
/etc/rc.d/rc.local_shutdown stop
|
||||
fi
|
||||
|
||||
# Stop the Apache web server:
|
||||
if [ -x /etc/rc.d/rc.httpd ]; then
|
||||
/etc/rc.d/rc.httpd stop
|
||||
fi
|
||||
|
||||
# Stop the Samba server:
|
||||
if [ -x /etc/rc.d/rc.samba ]; then
|
||||
/etc/rc.d/rc.samba stop
|
||||
fi
|
||||
|
||||
# Shut down the NFS server:
|
||||
if [ -x /etc/rc.d/rc.nfsd ]; then
|
||||
/etc/rc.d/rc.nfsd stop
|
||||
fi
|
||||
|
||||
# Kill any processes (typically gam) that would otherwise prevent
|
||||
# unmounting NFS volumes:
|
||||
unset FUSER_DELAY
|
||||
for dir in $(/bin/mount | grep -e 'type nfs ' -e 'type nfs4 ' | sed -e 's|.* on ||g' | cut -d ' ' -f 1) ; do
|
||||
echo "Killing processes holding NFS mount $dir open..."
|
||||
# Background this to prevent fuser from also blocking shutdown:
|
||||
/usr/bin/fuser -k -M -m "$dir" &
|
||||
FUSER_DELAY=5
|
||||
done
|
||||
# If fuser was run, let it have some delay:
|
||||
if [ ! -z "$FUSER_DELAY" ]; then
|
||||
sleep $FUSER_DELAY
|
||||
fi
|
||||
|
||||
# Unmount any NFS, SMB, or CIFS filesystems:
|
||||
echo "Unmounting remote filesystems:"
|
||||
/bin/umount -v -a -l -f -r -t nfs,nfs4,smbfs,cifs | tr -d ' ' | grep successfully | sed "s/:successfullyunmounted/ has been successfully unmounted./g"
|
||||
|
||||
# Shut down PCMCIA devices:
|
||||
if [ -x /etc/rc.d/rc.pcmcia ] ; then
|
||||
/etc/rc.d/rc.pcmcia stop
|
||||
# The cards might need a little extra time here to deactivate:
|
||||
sleep 5
|
||||
fi
|
||||
|
||||
# Terminate acpid before syslog:
|
||||
if [ -x /etc/rc.d/rc.acpid -a -r /var/run/acpid.pid ]; then # quit
|
||||
/etc/rc.d/rc.acpid stop
|
||||
fi
|
||||
|
||||
# Kill all processes.
|
||||
OMITPIDS="$(for p in $(pgrep mdmon); do echo -o $p; done)" # Don't kill mdmon
|
||||
echo
|
||||
echo "Sending all processes the SIGHUP signal."
|
||||
killall5 -1 $OMITPIDS
|
||||
echo -n "Waiting for processes to hang up"
|
||||
for loop in 0 1 2 3 4 5 ; do
|
||||
sleep 1
|
||||
echo -n "."
|
||||
done
|
||||
echo
|
||||
echo "Sending all processes the SIGTERM signal."
|
||||
killall5 -15 $OMITPIDS
|
||||
echo -n "Waiting for processes to terminate"
|
||||
for loop in 0 1 2 3 4 5 ; do
|
||||
sleep 1
|
||||
echo -n "."
|
||||
done
|
||||
echo
|
||||
echo "Sending all processes the SIGKILL signal."
|
||||
killall5 -9 $OMITPIDS
|
||||
echo -n "Waiting for processes to exit"
|
||||
for loop in 0 1 2 3 4 5 ; do
|
||||
sleep 1
|
||||
echo -n "."
|
||||
done
|
||||
echo
|
||||
|
||||
# Now go to the single user level
|
||||
echo "Going to single user mode..."
|
||||
/sbin/telinit -t 1 1
|
||||
|
||||
255
etc/rc.d/rc.M
Executable file
255
etc/rc.d/rc.M
Executable file
@@ -0,0 +1,255 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# rc.M This file is executed by init(8) when the system is being
|
||||
# initialized for one of the "multi user" run levels (i.e.
|
||||
# levels 1 through 6). It usually does mounting of file
|
||||
# systems et al.
|
||||
#
|
||||
# Version: @(#)/etc/rc.d/rc.M 15.0 Fri Nov 12 18:51:28 UTC 2021
|
||||
#
|
||||
# Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
|
||||
# Heavily modified by Patrick Volkerding <volkerdi@slackware.com>
|
||||
#
|
||||
# LimeTech - Modified for Unraid OS
|
||||
|
||||
# Tell the viewers what's going to happen.
|
||||
echo "Going multiuser..."
|
||||
|
||||
# Update all the shared library links:
|
||||
if [ -x /sbin/ldconfig ]; then
|
||||
echo "Updating shared library links: /sbin/ldconfig &"
|
||||
/sbin/ldconfig &
|
||||
fi
|
||||
|
||||
# Call the setterm init script to set screen blanking and power management
|
||||
# defaults:
|
||||
if [ -x /etc/rc.d/rc.setterm ]; then
|
||||
/etc/rc.d/rc.setterm
|
||||
fi
|
||||
|
||||
# Set the hostname:
|
||||
/bin/hostname $(cat /etc/HOSTNAME)
|
||||
|
||||
# Set the permissions on /var/log/dmesg according to whether the kernel
|
||||
# permits non-root users to access kernel dmesg information:
|
||||
if [ -r /proc/sys/kernel/dmesg_restrict ]; then
|
||||
if [ $(cat /proc/sys/kernel/dmesg_restrict) = 1 ]; then
|
||||
touch /var/log/dmesg
|
||||
chmod 640 /var/log/dmesg
|
||||
fi
|
||||
else
|
||||
touch /var/log/dmesg
|
||||
chmod 644 /var/log/dmesg
|
||||
fi
|
||||
# Save the contents of 'dmesg':
|
||||
/bin/dmesg -s 65536 > /var/log/dmesg
|
||||
|
||||
# Start the system logger.
|
||||
if [ -x /etc/rc.d/rc.rsyslog ]; then
|
||||
/etc/rc.d/rc.rsyslog start
|
||||
fi
|
||||
|
||||
# Update the X font indexes:
|
||||
if [ -x /usr/bin/fc-cache ]; then
|
||||
echo "Updating X font indexes: /usr/bin/fc-cache -f &"
|
||||
/usr/bin/fc-cache -f &
|
||||
fi
|
||||
|
||||
# Run rc.udev again. This will start udev if it is not already running
|
||||
# (for example, upon return from runlevel 1), otherwise it will trigger it
|
||||
# to look for device changes and to generate persistent rules if needed.
|
||||
if grep -wq sysfs /proc/mounts && grep -q devtmpfs /proc/filesystems ; then
|
||||
if ! grep -wq nohotplug /proc/cmdline ; then
|
||||
if [ -x /etc/rc.d/rc.udev ]; then
|
||||
/etc/rc.d/rc.udev start
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Initialize the networking hardware.
|
||||
if [ -x /etc/rc.d/rc.inet1 ]; then
|
||||
/etc/rc.d/rc.inet1
|
||||
fi
|
||||
|
||||
# Start D-Bus:
|
||||
if [ -x /etc/rc.d/rc.messagebus ]; then
|
||||
/etc/rc.d/rc.messagebus start
|
||||
fi
|
||||
|
||||
# Start the session/seat daemon:
|
||||
if [ -x /etc/rc.d/rc.elogind -a -x /bin/loginctl ]; then
|
||||
/etc/rc.d/rc.elogind start
|
||||
elif [ -x /etc/rc.d/rc.consolekit -a -x /usr/sbin/console-kit-daemon ]; then
|
||||
/etc/rc.d/rc.consolekit start
|
||||
fi
|
||||
|
||||
# Start Bluetooth:
|
||||
if [ -x /etc/rc.d/rc.bluetooth ]; then
|
||||
/etc/rc.d/rc.bluetooth start
|
||||
fi
|
||||
|
||||
# Start networking daemons:
|
||||
if [ -x /etc/rc.d/rc.inet2 ]; then
|
||||
/etc/rc.d/rc.inet2
|
||||
fi
|
||||
|
||||
# Mount any additional filesystem types that haven't already been mounted:
|
||||
mount -a -v 2> /dev/null | grep -v -e "already mounted" -e "ignored" | cut -f 1 -d : | tr -d ' ' | while read dev ; do mount | grep "${dev} " ; done
|
||||
|
||||
# Start the Network Time Protocol daemon:
|
||||
if [ -x /etc/rc.d/rc.ntpd ]; then
|
||||
/etc/rc.d/rc.ntpd start
|
||||
fi
|
||||
|
||||
# Remove stale locks and junk files (must be done after mount -a!)
|
||||
/bin/rm -f /var/lock/* /var/spool/uucp/LCK..* /tmp/.X*lock /tmp/.X11-unix/* 2> /dev/null
|
||||
|
||||
# Ensure basic filesystem permissions sanity.
|
||||
chmod 755 / 2> /dev/null
|
||||
chmod 1777 /tmp /var/tmp
|
||||
|
||||
# Start ACPI daemon.
|
||||
if [ -x /etc/rc.d/rc.acpid ]; then
|
||||
/etc/rc.d/rc.acpid start
|
||||
fi
|
||||
|
||||
# Enable CPU frequency scaling:
|
||||
if [ -x /etc/rc.d/rc.cpufreq ]; then
|
||||
/etc/rc.d/rc.cpufreq start
|
||||
fi
|
||||
|
||||
# Update any existing icon cache files:
|
||||
if find /usr/share/icons -maxdepth 2 2> /dev/null | grep -q icon-theme.cache ; then
|
||||
for theme_dir in /usr/share/icons/* ; do
|
||||
if [ -r ${theme_dir}/icon-theme.cache ]; then
|
||||
echo "Updating icon-theme.cache in ${theme_dir}..."
|
||||
/usr/bin/gtk-update-icon-cache -t -f ${theme_dir} 1> /dev/null 2> /dev/null &
|
||||
fi
|
||||
done
|
||||
# This would be a large file and probably shouldn't be there.
|
||||
if [ -r /usr/share/icons/icon-theme.cache ]; then
|
||||
echo "Deleting icon-theme.cache in /usr/share/icons..."
|
||||
#/usr/bin/gtk-update-icon-cache -t -f /usr/share/icons 1> /dev/null 2> /dev/null &
|
||||
rm -f /usr/share/icons/icon-theme.cache
|
||||
fi
|
||||
fi
|
||||
|
||||
# Update mime database:
|
||||
if [ -x /usr/bin/update-mime-database -a -d /usr/share/mime ]; then
|
||||
echo "Updating MIME database: /usr/bin/update-mime-database /usr/share/mime &"
|
||||
/usr/bin/update-mime-database /usr/share/mime 1> /dev/null 2> /dev/null &
|
||||
fi
|
||||
|
||||
# These GTK+/pango files need to be kept up to date for
|
||||
# proper input method, pixbuf loaders, and font support.
|
||||
if [ -x /usr/bin/update-gtk-immodules ]; then
|
||||
echo "Updating gtk.immodules:"
|
||||
echo " /usr/bin/update-gtk-immodules &"
|
||||
/usr/bin/update-gtk-immodules > /dev/null 2>&1 &
|
||||
fi
|
||||
if [ -x /usr/bin/update-gdk-pixbuf-loaders ]; then
|
||||
echo "Updating gdk-pixbuf.loaders:"
|
||||
echo " /usr/bin/update-gdk-pixbuf-loaders &"
|
||||
HOME=/root /usr/bin/update-gdk-pixbuf-loaders > /dev/null 2>&1 &
|
||||
fi
|
||||
if [ -x /usr/bin/update-pango-querymodules ]; then
|
||||
echo "Updating pango.modules:"
|
||||
echo " /usr/bin/update-pango-querymodules &"
|
||||
/usr/bin/update-pango-querymodules > /dev/null 2>&1 &
|
||||
fi
|
||||
if [ -x /usr/bin/glib-compile-schemas ]; then
|
||||
echo "Compiling GSettings XML schema files:"
|
||||
echo " /usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas &"
|
||||
/usr/bin/glib-compile-schemas /usr/share/glib-2.0/schemas >/dev/null 2>&1 &
|
||||
fi
|
||||
|
||||
# Start dnsmasq, a simple DHCP/DNS server:
|
||||
if [ -x /etc/rc.d/rc.dnsmasq ]; then
|
||||
/etc/rc.d/rc.dnsmasq start
|
||||
fi
|
||||
|
||||
# Start smartd, which monitors the status of S.M.A.R.T. compatible
|
||||
# hard drives and reports any problems:
|
||||
if [ -x /etc/rc.d/rc.smartd ]; then
|
||||
/etc/rc.d/rc.smartd start
|
||||
fi
|
||||
|
||||
# Turn on process accounting. To enable process accounting, make sure the
|
||||
# option for BSD process accounting is enabled in your kernel, and then
|
||||
# create the file /var/log/pacct (touch /var/log/pacct). By default, process
|
||||
# accounting is not enabled (since /var/log/pacct does not exist). This is
|
||||
# because the log file can get VERY large.
|
||||
if [ -x /sbin/accton -a -r /var/log/pacct ]; then
|
||||
chmod 640 /var/log/pacct
|
||||
/sbin/accton /var/log/pacct
|
||||
fi
|
||||
|
||||
# Start crond (Dillon's crond):
|
||||
if [ -x /etc/rc.d/rc.crond ]; then
|
||||
/etc/rc.d/rc.crond start
|
||||
fi
|
||||
|
||||
# Start atd (manages jobs scheduled with 'at'):
|
||||
if [ -x /etc/rc.d/rc.atd ]; then
|
||||
/etc/rc.d/rc.atd start
|
||||
fi
|
||||
|
||||
# Load a custom screen font if the user has an rc.font script.
|
||||
if [ -x /etc/rc.d/rc.font ]; then
|
||||
/etc/rc.d/rc.font
|
||||
fi
|
||||
|
||||
# Load a custom keymap if the user has an rc.keymap script.
|
||||
if [ -x /etc/rc.d/rc.keymap ]; then
|
||||
/etc/rc.d/rc.keymap
|
||||
fi
|
||||
|
||||
# Start the MariaDB database:
|
||||
if [ -x /etc/rc.d/rc.mysqld ]; then
|
||||
/etc/rc.d/rc.mysqld start
|
||||
fi
|
||||
|
||||
# Start the SASL authentication server. This provides SASL
|
||||
# authentication services for sendmail/postfix:
|
||||
if [ -x /etc/rc.d/rc.saslauthd ]; then
|
||||
/etc/rc.d/rc.saslauthd start
|
||||
fi
|
||||
|
||||
# Start OpenLDAP:
|
||||
if [ -x /etc/rc.d/rc.openldap ]; then
|
||||
/etc/rc.d/rc.openldap start
|
||||
fi
|
||||
|
||||
# Start WireGuard
|
||||
if [ -x /etc/rc.d/rc.wireguard ]; then
|
||||
/etc/rc.d/rc.wireguard start
|
||||
fi
|
||||
|
||||
# Start avahi:
|
||||
if [ -x /etc/rc.d/rc.avahidaemon ]; then
|
||||
/etc/rc.d/rc.avahidaemon start
|
||||
/etc/rc.d/rc.avahidnsconfd start
|
||||
fi
|
||||
|
||||
# Start Samba (a file/print server for Windows machines).
|
||||
# Samba can be started in /etc/inetd.conf instead.
|
||||
if [ -x /etc/rc.d/rc.samba ]; then
|
||||
/etc/rc.d/rc.samba start
|
||||
fi
|
||||
|
||||
# Start mcelog
|
||||
if [ -x /etc/rc.d/rc.mcelog ]; then
|
||||
/etc/rc.d/rc.mcelog start
|
||||
fi
|
||||
|
||||
# If there are SystemV init scripts for this runlevel, run them.
|
||||
if [ -x /etc/rc.d/rc.sysvinit ]; then
|
||||
/etc/rc.d/rc.sysvinit
|
||||
fi
|
||||
|
||||
# Start the local setup procedure.
|
||||
if [ -x /etc/rc.d/rc.local ]; then
|
||||
/etc/rc.d/rc.local
|
||||
fi
|
||||
|
||||
# All done.
|
||||
156
etc/rc.d/rc.S
Executable file
156
etc/rc.d/rc.S
Executable file
@@ -0,0 +1,156 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# /etc/rc.d/rc.S: System initialization script.
|
||||
#
|
||||
# Mostly written by: Patrick J. Volkerding, <volkerdi@slackware.com>
|
||||
# LimeTech - Modified for Unraid OS
|
||||
#
|
||||
|
||||
PATH=/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin
|
||||
|
||||
# Mount /proc if it is not already mounted:
|
||||
if [ ! -d /proc/sys ]; then
|
||||
/sbin/mount -v proc /proc -n -t proc 2> /dev/null
|
||||
fi
|
||||
|
||||
# Mount /sys if it is not already mounted:
|
||||
if [ ! -d /sys/kernel ]; then
|
||||
/sbin/mount -v sysfs /sys -n -t sysfs 2> /dev/null
|
||||
fi
|
||||
|
||||
# The efivarfs filesystem is used for reading and writing EFI variables, such
|
||||
# as the boot menu entries. By default efivarfs will be mounted read-write on
|
||||
# the /sys/firmware/efi/efivars directory. To modify this behavior, edit the
|
||||
# file: /etc/default/efivarfs
|
||||
# Only try to mount if this directory exists (so the kernel supports efivarfs):
|
||||
if [ -d /sys/firmware/efi/efivars ]; then
|
||||
# Only try to mount if efivarfs is not already mounted:
|
||||
if ! /sbin/mount | /bin/grep -wq efivarfs ; then
|
||||
# Mount according to /etc/default/efivarfs:
|
||||
if [ -r /etc/default/efivarfs ]; then
|
||||
. /etc/default/efivarfs
|
||||
else # default
|
||||
EFIVARFS=rw
|
||||
fi
|
||||
case "$EFIVARFS" in
|
||||
'rw')
|
||||
/sbin/mount -o rw -t efivarfs none /sys/firmware/efi/efivars
|
||||
;;
|
||||
'ro')
|
||||
/sbin/mount -o ro -t efivarfs none /sys/firmware/efi/efivars
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
# If /run exists, mount a tmpfs on it (unless the
|
||||
# initrd has already done so):
|
||||
if [ -d /run ]; then
|
||||
if ! /bin/grep -wq "tmpfs /run tmpfs" /proc/mounts ; then
|
||||
/sbin/mount -v -n -t tmpfs tmpfs /run -o mode=0755,size=32M,nodev,nosuid,noexec
|
||||
fi
|
||||
fi
|
||||
|
||||
# limetech - lets mount debugfs
|
||||
/sbin/mount -v -t debugfs none /sys/kernel/debug
|
||||
|
||||
# limetech - determine if the 'unraidlabel' kernel append parameter was
|
||||
# provided to override which device is mounted for /boot (default: UNRAID)
|
||||
UNRAIDLABEL="UNRAID"
|
||||
UNRAIDROOT=
|
||||
set -- $(cat /proc/cmdline)
|
||||
for x in "$@"; do
|
||||
case "$x" in
|
||||
unraidlabel=*)
|
||||
UNRAIDLABEL="${x#unraidlabel=}"
|
||||
;;
|
||||
root=*)
|
||||
UNRAIDROOT="${x#root=}"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# limetech - poll for device with $UNRAIDLABEL present, with 30-sec timeout
|
||||
# this serves to synchronize this script with USB subsystem
|
||||
abort() {
|
||||
read -p "$1 - press ENTER key to reboot ..."
|
||||
echo
|
||||
/sbin/reboot
|
||||
}
|
||||
find_device() {
|
||||
# find which USB flash device/partition has the indicated label
|
||||
local i
|
||||
for i in {1..30} ; do
|
||||
DEVICE=$(/sbin/blkid -L $UNRAIDLABEL)
|
||||
[[ -z $DEVICE ]] && sleep 1 || return 0
|
||||
done
|
||||
return 1
|
||||
}
|
||||
echo -n "waiting up to 30 sec for device with label $UNRAIDLABEL to come online ... "
|
||||
find_device && echo "found $DEVICE" || abort "not found"
|
||||
|
||||
echo "Checking $DEVICE ..."
|
||||
/sbin/fsck.fat -a -w $DEVICE 2>/dev/null
|
||||
|
||||
/sbin/mount -v -t vfat -o auto,rw,flush,noatime,nodiratime,dmask=77,fmask=177,shortname=mixed $DEVICE /boot || abort "cannot mount $DEVICE"
|
||||
|
||||
# check initial files used to boot
|
||||
bzcheck () {
|
||||
local BZFILE=$1
|
||||
if [[ -f /boot/config/skipbzcheck ]]; then
|
||||
echo "Skipping $BZFILE checksum verification"
|
||||
return
|
||||
fi
|
||||
echo "Verifying $BZFILE checksum ..."
|
||||
[[ ! -f "/boot/$BZFILE" ]] && abort "$BZFILE not present"
|
||||
local BZFILECHK="$BZFILE.sha256"
|
||||
[[ ! -f "/boot/$BZFILECHK" ]] && abort "$BZFILECHK not present"
|
||||
local SUM1=$(/bin/sha256sum /boot/$BZFILE)
|
||||
local SUM2=$(/bin/cat /boot/$BZFILECHK)
|
||||
[[ "${SUM1:0:63}" != "${SUM2:0:63}" ]] && abort "$BZFILE checksum error"
|
||||
}
|
||||
bzmount () {
|
||||
local BZFILE=$1
|
||||
local MNTDIR=$2
|
||||
bzcheck $BZFILE
|
||||
/bin/mkdir -p /$MNTDIR
|
||||
/sbin/mount -v -r -t squashfs /boot/$BZFILE /$MNTDIR || abort "cannot mount $BZFILE"
|
||||
# setup an overlayfs
|
||||
/bin/mkdir -p /var/local/overlay/$MNTDIR
|
||||
/bin/mkdir -p /var/local/overlay-work/$MNTDIR
|
||||
/sbin/mount -v -t overlay overlay -o lowerdir=/$MNTDIR,upperdir=/var/local/overlay/$MNTDIR,workdir=/var/local/overlay-work/$MNTDIR /$MNTDIR
|
||||
}
|
||||
if [[ $UNRAIDROOT == "" ]]; then
|
||||
bzcheck "bzimage"
|
||||
bzcheck "bzroot"
|
||||
bzcheck "bzroot-gui"
|
||||
|
||||
bzmount "bzmodules" "lib"
|
||||
bzmount "bzfirmware" "usr"
|
||||
|
||||
# now that /usr is mounted make /etc/rc.d a symlink
|
||||
/bin/rm -r /etc/rc.d
|
||||
/bin/ln -s /usr/local/etc/rc.d /etc
|
||||
|
||||
# move /var/log to a tmpfs
|
||||
/bin/mv /var/log/* /var/empty
|
||||
/sbin/mount -t tmpfs -o size=128m,mode=0755 tmpfs /var/log
|
||||
/bin/mv /var/empty/* /var/log
|
||||
else
|
||||
echo "Checking root filesystem"
|
||||
/sbin/fsck -C -a $UNRAIDROOT
|
||||
RETVAL=$?
|
||||
[[ $RETVAL -ge 2 ]] && abort "fsck failed with return value $RETVAL"
|
||||
# Remount the root filesystem in read-write mode
|
||||
echo "Remounting $UNRAIDROOT with read-write enabled."
|
||||
/sbin/mount -w -v -n -o remount /
|
||||
RETVAL=$?
|
||||
[[ $RETVAL -gt 0 ]] && abort "failed to remount $UNRAIDROOT r/w with return value $RETVAL"
|
||||
fi
|
||||
|
||||
# invoke testing hook
|
||||
if [[ -f /boot/config/rc.S.extra ]]; then
|
||||
source /boot/config/rc.S.extra
|
||||
fi
|
||||
# and continue in separate script
|
||||
source /etc/rc.d/rc.S.cont
|
||||
243
etc/rc.d/rc.S.cont
Executable file
243
etc/rc.d/rc.S.cont
Executable file
@@ -0,0 +1,243 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# /etc/rc.d/rc.S: System initialization script (continuation)
|
||||
#
|
||||
# Mostly written by: Patrick J. Volkerding, <volkerdi@slackware.com>
|
||||
# LimeTech - Modified for Unraid OS
|
||||
#
|
||||
|
||||
# source'ed by rc.S
|
||||
|
||||
# limetech - bind selected devices to vfio-pci
|
||||
/usr/local/sbin/vfio-pci 1> /var/log/vfio-pci 2> /var/log/vfio-pci-errors
|
||||
|
||||
# Run the kernel module script. This updates the module dependencies and
|
||||
# also supports manually loading kernel modules through rc.modules.local.
|
||||
if [ -x /etc/rc.d/rc.modules ]; then
|
||||
/etc/rc.d/rc.modules
|
||||
fi
|
||||
|
||||
# Initialize udev to manage /dev entries and hotplugging.
|
||||
# You may turn off udev by making the /etc/rc.d/rc.udev file non-executable
|
||||
# or giving the "nohotplug" option at boot, but realize that if you turn off
|
||||
# udev that you will have to load all the kernel modules that you need
|
||||
# yourself (possibly in /etc/rc.d/rc.modules.local), and make any additional
|
||||
# device nodes that you need in the /dev directory. Even USB and IEEE1394
|
||||
# devices will need to have the modules loaded by hand if udev is not used.
|
||||
# So use it. :-)
|
||||
if grep -wq sysfs /proc/mounts && grep -q devtmpfs /proc/filesystems ; then
|
||||
if ! grep -wq nohotplug /proc/cmdline ; then
|
||||
if [ -x /etc/rc.d/rc.udev ]; then
|
||||
/etc/rc.d/rc.udev start
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Mount Control Groups filesystem interface:
|
||||
if grep -wq cgroup /proc/filesystems ; then
|
||||
# Christoph H. - Check if unraidcgroup1 is passed over in command line
|
||||
if grep -wq unraidcgroup1 /proc/cmdline ; then
|
||||
if [ -d /sys/fs/cgroup ]; then
|
||||
# See linux-*/Documentation/cgroups/cgroups.txt (section 1.6)
|
||||
# Check if we have some tools to autodetect the available cgroup controllers
|
||||
if [ -x /bin/cut -a -x /bin/tail ]; then
|
||||
# Mount a tmpfs as the cgroup filesystem root
|
||||
mount -t tmpfs -o mode=0755,size=8M cgroup_root /sys/fs/cgroup
|
||||
# Autodetect available controllers and mount them in subfolders
|
||||
controllers="$(/bin/cut -f 1 /proc/cgroups | /bin/tail -n +2)"
|
||||
for i in $controllers; do
|
||||
mkdir /sys/fs/cgroup/$i
|
||||
mount -t cgroup -o $i $i /sys/fs/cgroup/$i
|
||||
done
|
||||
unset i controllers
|
||||
# Eric S. figured out this needs to go here...
|
||||
echo 1 > /sys/fs/cgroup/memory/memory.use_hierarchy
|
||||
else
|
||||
# We can't use autodetection so fall back mounting them all together
|
||||
mount -t cgroup cgroup /sys/fs/cgroup
|
||||
fi
|
||||
else
|
||||
mkdir -p /dev/cgroup
|
||||
mount -t cgroup cgroup /dev/cgroup
|
||||
fi
|
||||
else
|
||||
if [ -d /sys/fs/cgroup ]; then
|
||||
# See https://docs.kernel.org/admin-guide/cgroup-v2.html (section Mounting)
|
||||
# Mount a tmpfs as the cgroup2 filesystem root
|
||||
mount -t tmpfs -o mode=0755,size=8M cgroup_root /sys/fs/cgroup
|
||||
mount -t cgroup2 none /sys/fs/cgroup
|
||||
else
|
||||
mkdir -p /dev/cgroup
|
||||
mount -t cgroup2 none /dev/cgroup
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Huge page support:
|
||||
mount /hugetlbfs
|
||||
|
||||
# Enable swapping:
|
||||
/sbin/swapon -a 2> /dev/null
|
||||
|
||||
# Set the tick and frequency for the system clock.
|
||||
# Default values are: TICK=10000 and FREQ=0
|
||||
TICK=10000
|
||||
FREQ=0
|
||||
# If there's a /etc/default/adjtimex config file, source it to override
|
||||
# the default TICK and FREQ:
|
||||
if [ -r /etc/default/adjtimex ]; then
|
||||
. /etc/default/adjtimex
|
||||
fi
|
||||
if /sbin/adjtimex --tick $TICK --frequency $FREQ; then
|
||||
echo "Setting the system clock rate: /sbin/adjtimex --tick $TICK --frequency $FREQ"
|
||||
else
|
||||
echo "Failed to set system clock with adjtimex, possibly invalid parameters? (TICK=$TICK FREQ=$FREQ)"
|
||||
fi
|
||||
|
||||
# Set the system time from the hardware clock using hwclock --hctosys.
|
||||
if [ -x /sbin/hwclock ]; then
|
||||
# Check for a broken motherboard RTC clock (where ioports for rtc are
|
||||
# unknown) to prevent hwclock causing a hang:
|
||||
if ! grep -q " : rtc" /proc/ioports ; then
|
||||
CLOCK_OPT="--directisa"
|
||||
fi
|
||||
if [ /etc/adjtime -nt /etc/hardwareclock ]; then
|
||||
if grep -q "^LOCAL" /etc/adjtime ; then
|
||||
echo -n "Setting system time from the hardware clock (localtime): "
|
||||
else
|
||||
echo -n "Setting system time from the hardware clock (UTC): "
|
||||
fi
|
||||
/sbin/hwclock $CLOCK_OPT --hctosys
|
||||
elif grep -wq "^localtime" /etc/hardwareclock 2> /dev/null ; then
|
||||
echo -n "Setting system time from the hardware clock (localtime): "
|
||||
/sbin/hwclock $CLOCK_OPT --localtime --hctosys
|
||||
else
|
||||
echo -n "Setting system time from the hardware clock (UTC): "
|
||||
/sbin/hwclock $CLOCK_OPT --utc --hctosys
|
||||
fi
|
||||
date
|
||||
fi
|
||||
|
||||
# Configure ISA Plug-and-Play devices:
|
||||
if [ -r /etc/isapnp.conf ]; then
|
||||
if [ -x /sbin/isapnp ]; then
|
||||
/sbin/isapnp /etc/isapnp.conf
|
||||
fi
|
||||
fi
|
||||
|
||||
# Configure kernel parameters:
|
||||
if [ -x /sbin/sysctl -a -r /etc/sysctl.conf ]; then
|
||||
echo "Configuring kernel parameters: /sbin/sysctl -e --system"
|
||||
/sbin/sysctl -e --system
|
||||
elif [ -x /sbin/sysctl ]; then
|
||||
echo "Configuring kernel parameters: /sbin/sysctl -e --system"
|
||||
# Don't say "Applying /etc/sysctl.conf" or complain if the file doesn't exist
|
||||
/sbin/sysctl -e --system 2> /dev/null | grep -v "Applying /etc/sysctl.conf"
|
||||
fi
|
||||
|
||||
# Clean up some temporary files:
|
||||
rm -f /etc/nologin /etc/dhcpc/*.pid /etc/forcefsck /etc/fastboot \
|
||||
/var/state/saslauthd/saslauthd.pid /tmp/.Xauth* 1> /dev/null 2> /dev/null
|
||||
rm -rf /tmp/{kde-[a-zA-Z]*,ksocket-[a-zA-Z]*,hsperfdata_[a-zA-Z]*,plugtmp*}
|
||||
if [ -d /var/lib/pkgtools/setup/tmp ]; then
|
||||
( cd /var/lib/pkgtools/setup/tmp && rm -rf * )
|
||||
elif [ -d /var/log/setup/tmp ]; then
|
||||
( cd /var/log/setup/tmp && rm -rf * )
|
||||
fi
|
||||
|
||||
# Clear /var/lock/subsys:
|
||||
if [ -d /var/lock/subsys ]; then
|
||||
rm -f /var/lock/subsys/*
|
||||
fi
|
||||
|
||||
# Start libcgroup services:
|
||||
if [ -x /etc/rc.d/rc.cgconfig -a -x /etc/rc.d/rc.cgred -a -d /sys/fs/cgroup ]; then
|
||||
/etc/rc.d/rc.cgconfig start ; echo " /usr/sbin/cgconfigparser -l /etc/cgconfig.conf"
|
||||
/etc/rc.d/rc.cgred start
|
||||
fi
|
||||
|
||||
# Create /tmp/{.ICE-unix,.X11-unix} if they are not present:
|
||||
if [ ! -e /tmp/.ICE-unix ]; then
|
||||
mkdir -p /tmp/.ICE-unix
|
||||
chmod 1777 /tmp/.ICE-unix
|
||||
fi
|
||||
if [ ! -e /tmp/.X11-unix ]; then
|
||||
mkdir -p /tmp/.X11-unix
|
||||
chmod 1777 /tmp/.X11-unix
|
||||
fi
|
||||
|
||||
# Create a fresh utmp file:
|
||||
touch /var/run/utmp
|
||||
chown root:utmp /var/run/utmp
|
||||
chmod 664 /var/run/utmp
|
||||
|
||||
# In case pam_faillock(8) is being used, create the tally directory:
|
||||
mkdir -p /var/run/faillock
|
||||
|
||||
# If there are SystemV init scripts for this runlevel, run them.
|
||||
if [ -x /etc/rc.d/rc.sysvinit ]; then
|
||||
/etc/rc.d/rc.sysvinit
|
||||
fi
|
||||
|
||||
# Run serial port setup script:
|
||||
# CAREFUL! This can make some systems hang if the rc.serial script isn't
|
||||
# set up correctly. If this happens, you may have to edit the file from a
|
||||
# boot disk, and/or set it as non-executable:
|
||||
if [ -x /etc/rc.d/rc.serial ]; then
|
||||
/etc/rc.d/rc.serial start
|
||||
fi
|
||||
|
||||
# limetech - let's keep this on the USB flash
|
||||
## Carry an entropy pool between reboots to improve randomness.
|
||||
mkdir -p /var/lib/seedrng
|
||||
chmod 600 /var/lib/seedrng
|
||||
cp /boot/config/random-seed /var/lib/seedrng/seed.no-credit 2>/dev/null
|
||||
/usr/sbin/seedrng
|
||||
|
||||
# limetech - restore hostname from ident.cfg file on flash and ensure hostname is
|
||||
# defined as localhost alias in /etc/hosts (this lets wins name resolution work)
|
||||
NAME="Tower"
|
||||
timeZone="America/Los_Angeles"
|
||||
if [ -r /boot/config/ident.cfg ]; then
|
||||
source <(/usr/bin/fromdos < /boot/config/ident.cfg)
|
||||
NAME=${NAME//[^a-zA-Z\-\.0-9]/\-}
|
||||
fi
|
||||
echo "$NAME" >/etc/HOSTNAME
|
||||
echo "# Generated" >/etc/hosts
|
||||
echo "127.0.0.1 $NAME localhost" >>/etc/hosts
|
||||
echo "54.149.176.35 keys.lime-technology.com" >>/etc/hosts
|
||||
|
||||
# limetech - restore the configured timezone
|
||||
if [ "$timeZone" = "custom" ]; then
|
||||
ln -sf /boot/config/timezone /etc/localtime
|
||||
else
|
||||
ln -sf /usr/share/zoneinfo/$timeZone /etc/localtime
|
||||
fi
|
||||
|
||||
# limetech - restore password files stored on flash
|
||||
if [ -r /boot/config/passwd ]; then
|
||||
while IFS=: read -r username password userid groupid comment homedir cmdshell ; do
|
||||
if [[ $username = root ]]; then
|
||||
sed -i "s|^root:.*|root:x:0:0:$comment:/root:/bin/bash|" /etc/passwd
|
||||
fi
|
||||
if (( userid >= 1000 )); then
|
||||
echo "$username:x:$userid:$groupid:$comment:/:/bin/false" >> /etc/passwd
|
||||
fi
|
||||
done < /boot/config/passwd
|
||||
if [ -r /boot/config/shadow ]; then
|
||||
cp /boot/config/shadow /etc
|
||||
chmod 600 /etc/shadow
|
||||
fi
|
||||
fi
|
||||
/usr/sbin/pwconv
|
||||
if [ -r /boot/config/smbpasswd ]; then
|
||||
cp /boot/config/smbpasswd /var/lib/samba/private
|
||||
fi
|
||||
if [ -r /boot/config/secrets.tdb ]; then
|
||||
cp /boot/config/secrets.tdb /var/lib/samba/private
|
||||
fi
|
||||
|
||||
# limetech - restore custom rsyslog.conf config file from flash if present
|
||||
if [ -r /boot/config/rsyslog.conf ]; then
|
||||
/usr/bin/fromdos </boot/config/rsyslog.conf >/etc/rsyslog.conf
|
||||
fi
|
||||
40
etc/rc.d/rc.acpid
Executable file
40
etc/rc.d/rc.acpid
Executable file
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
# Start/stop/restart acpid.
|
||||
|
||||
# Start acpid:
|
||||
acpid_start() {
|
||||
if [ -x /usr/sbin/acpid -a -d /proc/acpi ]; then
|
||||
echo "Starting ACPI daemon: /usr/sbin/acpid"
|
||||
/usr/sbin/acpid
|
||||
fi
|
||||
}
|
||||
|
||||
# Stop acpid:
|
||||
acpid_stop() {
|
||||
if [ -r /var/run/acpid.pid ]; then
|
||||
kill $(cat /var/run/acpid.pid)
|
||||
else
|
||||
killall acpid
|
||||
fi
|
||||
}
|
||||
|
||||
# Restart acpid:
|
||||
acpid_restart() {
|
||||
acpid_stop
|
||||
sleep 1
|
||||
acpid_start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
acpid_start
|
||||
;;
|
||||
'stop')
|
||||
acpid_stop
|
||||
;;
|
||||
'restart')
|
||||
acpid_restart
|
||||
;;
|
||||
*)
|
||||
echo "usage $0 start|stop|restart"
|
||||
esac
|
||||
39
etc/rc.d/rc.atd
Executable file
39
etc/rc.d/rc.atd
Executable file
@@ -0,0 +1,39 @@
|
||||
#!/bin/sh
|
||||
# /etc/rc.d/rc.atd - start/stop the at daemon
|
||||
|
||||
# To change the default options, edit /etc/default/atd.
|
||||
if [ -r /etc/default/atd ]; then
|
||||
. /etc/default/atd
|
||||
fi
|
||||
|
||||
start_atd() {
|
||||
if ! /usr/bin/pgrep --ns $$ --euid daemon -f "^/usr/sbin/atd" 1> /dev/null 2> /dev/null ; then
|
||||
echo "Starting atd: /usr/sbin/atd $ATD_OPTS"
|
||||
/usr/sbin/atd $ATD_OPTS
|
||||
fi
|
||||
}
|
||||
|
||||
stop_atd() {
|
||||
echo "Stopping atd."
|
||||
/usr/bin/pkill --ns $$ --euid daemon -f "^/usr/sbin/atd" 2> /dev/null
|
||||
}
|
||||
|
||||
restart_atd() {
|
||||
stop_atd
|
||||
sleep 1
|
||||
start_atd
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
start_atd
|
||||
;;
|
||||
'stop')
|
||||
stop_atd
|
||||
;;
|
||||
'restart')
|
||||
restart_atd
|
||||
;;
|
||||
*)
|
||||
echo "usage $0 start|stop|restart"
|
||||
esac
|
||||
136
etc/rc.d/rc.bind
Normal file
136
etc/rc.d/rc.bind
Normal file
@@ -0,0 +1,136 @@
|
||||
#!/bin/sh
|
||||
# Start/stop/restart the BIND name server daemon (named).
|
||||
|
||||
# Start BIND. By default this will run with user "named". If you'd like to
|
||||
# change this or other options, see: /etc/default/named
|
||||
|
||||
# You might also consider running BIND in a "chroot jail",
|
||||
# a discussion of which may be found in
|
||||
# /usr/doc/Linux-HOWTOs/Chroot-BIND-HOWTO.
|
||||
|
||||
# One last note: rndc has a lot of other nice features that it is not
|
||||
# within the scope of this start/stop/restart script to support.
|
||||
# For more details, see "man rndc" or just type "rndc" to see the options.
|
||||
|
||||
# Load command defaults:
|
||||
if [ -f /etc/default/named ] ; then . /etc/default/named ; fi
|
||||
if [ -f /etc/default/rndc ] ; then . /etc/default/rndc ; fi
|
||||
|
||||
# In case /etc/default/named was missing, provide fallbacks:
|
||||
if [ -z "$NAMED_USER" ]; then
|
||||
NAMED_USER="named"
|
||||
fi
|
||||
if [ -z "$NAMED_GROUP" ]; then
|
||||
NAMED_GROUP="named"
|
||||
fi
|
||||
if [ -z "$NAMED_OPTIONS" ]; then
|
||||
NAMED_OPTIONS="-u $NAMED_USER"
|
||||
fi
|
||||
|
||||
# Sanity check. If /usr/sbin/named is missing then it
|
||||
# doesn't make much sense to try to run this script:
|
||||
if [ ! -x /usr/sbin/named ]; then
|
||||
echo "/etc/rc.d/rc.bind: no /usr/sbin/named found (or not executable); cannot start."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start BIND. As many times as you like. ;-)
|
||||
# Seriously, don't run "rc.bind start" if BIND is already
|
||||
# running or you'll get more than one copy running.
|
||||
bind_start() {
|
||||
# Make sure /var/run/named exists:
|
||||
mkdir -p /var/run/named
|
||||
# Make sure that /var/run/named has correct ownership:
|
||||
chown -R ${NAMED_USER}:${NAMED_GROUP} /var/run/named
|
||||
# Make sure that /var/named has correct ownership:
|
||||
chown -R ${NAMED_USER}:${NAMED_GROUP} /var/named
|
||||
if [ -r /etc/rndc.key ]; then
|
||||
# Make sure that /etc/rndc.key has correct ownership:
|
||||
chown ${NAMED_USER}:${NAMED_GROUP} /etc/rndc.key
|
||||
fi
|
||||
# Start named:
|
||||
if [ -x /usr/sbin/named ]; then
|
||||
echo "Starting BIND: /usr/sbin/named $NAMED_OPTIONS"
|
||||
/usr/sbin/named $NAMED_OPTIONS
|
||||
sleep 1
|
||||
fi
|
||||
# Make sure that named started:
|
||||
if ! ps axc | grep -q named ; then
|
||||
echo "WARNING: named did not start."
|
||||
echo "Attempting to start named again: /usr/sbin/named $NAMED_OPTIONS"
|
||||
/usr/sbin/named $NAMED_OPTIONS
|
||||
sleep 1
|
||||
if ps axc | grep -q named ; then
|
||||
echo "SUCCESS: named started."
|
||||
else
|
||||
echo "FAILED: Sorry, a second attempt to start named has also failed."
|
||||
echo "There may be a configuration error that needs fixing. Good luck!"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Stop all running copies of BIND (/usr/sbin/named):
|
||||
bind_stop() {
|
||||
# If you've set up rndc, we can use this to make shutting down BIND faster.
|
||||
# If you have /etc/rndc.conf, or you have /etc/rndc.key, or $RNDC_OPTIONS is
|
||||
# not empty, we'll try it.
|
||||
if [ -r /etc/rndc.conf -o -r /etc/rndc.key -o ! -z "$RNDC_OPTIONS" ]; then
|
||||
if [ -z "$RNDC_OPTIONS" ]; then
|
||||
echo "Stopping BIND: /usr/sbin/rndc stop"
|
||||
else
|
||||
echo "Stopping BIND: /usr/sbin/rndc $RNDC_OPTIONS stop"
|
||||
fi
|
||||
/usr/sbin/rndc $RNDC_OPTIONS stop
|
||||
# Wait for up to $TIMEOUT seconds before moving on to try killall:
|
||||
TIMEOUT=${TIMEOUT:-10}
|
||||
while [ "$TIMEOUT" -gt "0" ]; do
|
||||
# Exit the timeout loop if there are no named processes:
|
||||
if ! ps axco command | grep -q -e "^named$"; then
|
||||
break
|
||||
fi
|
||||
sleep 1
|
||||
TIMEOUT=$(expr $TIMEOUT - 1)
|
||||
done
|
||||
fi
|
||||
# Kill named processes if there are any running:
|
||||
if ps axco command | grep -q -e "^named$"; then
|
||||
echo "Stopping all named processes in this namespace: /bin/killall -SIGTERM --ns \$\$ named"
|
||||
/bin/killall -SIGTERM --ns $$ named 2> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
# Reload BIND:
|
||||
bind_reload() {
|
||||
/usr/sbin/rndc $RNDC_OPTIONS reload
|
||||
}
|
||||
|
||||
# Restart BIND:
|
||||
bind_restart() {
|
||||
bind_stop
|
||||
bind_start
|
||||
}
|
||||
|
||||
# Get BIND status:
|
||||
bind_status() {
|
||||
/usr/sbin/rndc $RNDC_OPTIONS status
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
bind_start
|
||||
;;
|
||||
'stop')
|
||||
bind_stop
|
||||
;;
|
||||
'reload')
|
||||
bind_reload
|
||||
;;
|
||||
'restart')
|
||||
bind_restart
|
||||
;;
|
||||
'status')
|
||||
bind_status
|
||||
;;
|
||||
*)
|
||||
echo "usage $0 start|stop|reload|restart|status"
|
||||
esac
|
||||
202
etc/rc.d/rc.cgconfig
Normal file
202
etc/rc.d/rc.cgconfig
Normal file
@@ -0,0 +1,202 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-only
|
||||
#
|
||||
# Start/Stop the workload manager
|
||||
#
|
||||
# Copyright IBM Corporation. 2008
|
||||
#
|
||||
# Authors: Balbir Singh <balbir@linux.vnet.ibm.com>
|
||||
#
|
||||
# cgconfig Control Groups Configuration Startup
|
||||
# chkconfig: - 5 95
|
||||
# description: This script runs the cgconfigparser utility to parse and setup
|
||||
# the control group filesystem. It uses /etc/cgconfig.conf
|
||||
# and parses the configuration specified in there.
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: cgconfig
|
||||
# Required-Start:
|
||||
# Required-Stop:
|
||||
# Should-Start: ypbind
|
||||
# Should-Stop: ypbind
|
||||
# Short-Description: Create and setup control group filesystem(s)
|
||||
# Description: Create and setup control group filesystem(s)
|
||||
### END INIT INFO
|
||||
|
||||
# get correct location of binaries from configure
|
||||
sbindir=${exec_prefix}/sbin
|
||||
CGCONFIGPARSER_BIN=$sbindir/cgconfigparser
|
||||
CONFIG_FILE=/etc/cgconfig.conf
|
||||
CONFIG_DIR=/etc/cgconfig.d
|
||||
servicename=cgconfig
|
||||
|
||||
|
||||
lockfile=/run/lock/subsys/$servicename
|
||||
|
||||
# read the config
|
||||
CREATE_DEFAULT=yes
|
||||
if [ -e /etc/sysconfig/cgconfig ]; then
|
||||
# shellcheck disable=SC1091
|
||||
source /etc/sysconfig/cgconfig
|
||||
fi
|
||||
|
||||
lockfiledir=$(dirname "$lockfile")
|
||||
|
||||
create_default_groups() {
|
||||
defaultcgroup=
|
||||
|
||||
if [ -f /etc/cgrules.conf ]; then
|
||||
# shellcheck disable=SC2034
|
||||
read -r user ctrl defaultcgroup <<< \
|
||||
"$(grep -m1 '^\*[[:space:]]\+' /etc/cgrules.conf)"
|
||||
if [[ ( -n "$defaultcgroup" ) && ( "$defaultcgroup" = "*" ) ]]; then
|
||||
echo "/etc/cgrules.conf incorrect"
|
||||
echo "Overriding it"
|
||||
defaultcgroup=
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ -z "$defaultcgroup" ]]
|
||||
then
|
||||
defaultcgroup=sysdefault/
|
||||
fi
|
||||
|
||||
#
|
||||
# Find all mounted subsystems and create comma-separated list
|
||||
# of controllers.
|
||||
#
|
||||
controllers=$(lssubsys 2>/dev/null | tr '\n' ',' | sed s/.$//)
|
||||
|
||||
#
|
||||
# Create the default group, ignore errors when the default group
|
||||
# already exists.
|
||||
#
|
||||
cgcreate -f 664 -d 775 -g "$controllers":"$defaultcgroup" 2>/dev/null
|
||||
|
||||
#
|
||||
# special rule for cpusets
|
||||
#
|
||||
if echo "$controllers" | grep -q -w cpuset; then
|
||||
cpus=$(cgget -nv -r cpuset.cpus /)
|
||||
cgset -r cpuset.cpus="$cpus $defaultcgroup"
|
||||
mems=$(cgget -nv -r cpuset.mems /)
|
||||
cgset -r cpuset.mems="$mems $defaultcgroup"
|
||||
fi
|
||||
|
||||
#
|
||||
# Classify everything to default cgroup. Ignore errors, some processes
|
||||
# may exit after ps is run and before cgclassify moves them.
|
||||
#
|
||||
cgclassify -g "$controllers:$defaultcgroup $(ps --no-headers -eL o tid)" \
|
||||
2>/dev/null || :
|
||||
}
|
||||
|
||||
start() {
|
||||
printf "Starting %s service: " "$servicename"
|
||||
if [[ -f "$lockfile" ]]; then
|
||||
echo "lock file already exists"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ ! -s "$CONFIG_FILE" ]]; then
|
||||
echo $CONFIG_FILE "is not configured"
|
||||
return 6
|
||||
fi
|
||||
|
||||
|
||||
if ! "$CGCONFIGPARSER_BIN" -l "$CONFIG_FILE" -L "$CONFIG_DIR"
|
||||
then
|
||||
echo "Failed to parse " "$CONFIG_FILE" "or" "$CONFIG_DIR"'/*'
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ $CREATE_DEFAULT = "yes" ]; then
|
||||
create_default_groups
|
||||
fi
|
||||
|
||||
if ! mkdir -p "$lockfiledir" ; then
|
||||
echo "Failed to mkdir $lockfiledir directory"
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
if ! touch "$lockfile" ; then
|
||||
echo "Failed to touch $lockfile"
|
||||
return 1
|
||||
fi
|
||||
echo "Started $servicename"
|
||||
return 0
|
||||
}
|
||||
|
||||
stop() {
|
||||
printf "Stopping %s service is not supported!: " "$servicename"
|
||||
echo "Failed to stop $servicename"
|
||||
return 1
|
||||
}
|
||||
|
||||
trapped() {
|
||||
#
|
||||
# Do nothing
|
||||
#
|
||||
true
|
||||
}
|
||||
|
||||
usage() {
|
||||
echo "$0 <start|stop|restart|condrestart|status>"
|
||||
exit 2
|
||||
}
|
||||
|
||||
common() {
|
||||
#
|
||||
# main script work done here
|
||||
#
|
||||
trap "trapped ABRT" ABRT
|
||||
trap "trapped QUIT" QUIT
|
||||
trap "trapped TERM" TERM
|
||||
trap "trapped INT" INT
|
||||
}
|
||||
|
||||
restart() {
|
||||
common
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
RETVAL=0
|
||||
|
||||
case $1 in
|
||||
'stop')
|
||||
common
|
||||
stop
|
||||
RETVAL=$?
|
||||
;;
|
||||
'start')
|
||||
common
|
||||
start
|
||||
RETVAL=$?
|
||||
;;
|
||||
'restart'|'reload')
|
||||
restart
|
||||
RETVAL=$?
|
||||
;;
|
||||
'condrestart')
|
||||
if [[ -f "$lockfile" ]]; then
|
||||
restart
|
||||
RETVAL=$?
|
||||
fi
|
||||
;;
|
||||
'status')
|
||||
if [ -f "$lockfile" ]; then
|
||||
echo "Running"
|
||||
exit 0
|
||||
else
|
||||
echo "Stopped"
|
||||
exit 3
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
170
etc/rc.d/rc.cgred
Normal file
170
etc/rc.d/rc.cgred
Normal file
@@ -0,0 +1,170 @@
|
||||
#!/bin/bash
|
||||
# SPDX-License-Identifier: LGPL-2.1-only
|
||||
#
|
||||
# Start/Stop the CGroups Rules Engine Daemon
|
||||
#
|
||||
# Copyright Red Hat Inc. 2008
|
||||
#
|
||||
# Authors: Steve Olivieri <sjo@redhat.com>
|
||||
#
|
||||
# cgred CGroups Rules Engine Daemon
|
||||
# chkconfig: - 14 86
|
||||
# description: This is a daemon for automatically classifying processes \
|
||||
# into cgroups based on UID/GID.
|
||||
#
|
||||
# processname: cgrulesengd
|
||||
# pidfile: /var/run/cgred.pid
|
||||
#
|
||||
### BEGIN INIT INFO
|
||||
# Provides: cgrulesengd
|
||||
# Required-Start: $local_fs $syslog $cgconfig
|
||||
# Required-Stop: $local_fs $syslog
|
||||
# Should-Start:
|
||||
# Should-Stop:
|
||||
# Short-Description: start and stop the cgroups rules engine daemon
|
||||
# Description: CGroup Rules Engine is a tool for automatically using \
|
||||
# cgroups to classify processes
|
||||
### END INIT INFO
|
||||
|
||||
sbindir=${exec_prefix}/sbin
|
||||
CGRED_BIN=$sbindir/cgrulesengd
|
||||
|
||||
# Sanity checks
|
||||
[[ -x $CGRED_BIN ]] || exit 1
|
||||
|
||||
#
|
||||
# Source LSB routines
|
||||
#
|
||||
SYSLIBFILE=/etc/rc.d/init.d/functions
|
||||
OLDSYSLIBFILE=/etc/init.d/functions
|
||||
if [[ -x $SYSLIBFILE ]] ; then
|
||||
# shellcheck disable=SC1090
|
||||
source $SYSLIBFILE
|
||||
elif [[ -x $OLDSYSLIBFILE ]] ; then
|
||||
# shellcheck disable=SC1090
|
||||
source $OLDSYSLIBFILE
|
||||
log_warning_msg() ( warning "$@" ; printf "\n" 1>&2 ; )
|
||||
log_failure_msg() ( failure "$@" ; printf "\n" 1>&2 ; )
|
||||
log_success_msg() ( success "$@" ; printf "\n" 1>&2 ; )
|
||||
else
|
||||
log_warning_msg() ( printf "warning:%s\n" "$@" 1>&2 ;)
|
||||
log_failure_msg() ( printf "failure:%s\n" "$@" 1>&2 ;)
|
||||
log_success_msg() ( printf "success:%s\n" "$@" 1>&2 ;)
|
||||
fi
|
||||
|
||||
# Read in configuration options.
|
||||
if [[ -f "/etc/cgred.conf" ]] ; then
|
||||
# shellcheck disable=SC1091
|
||||
source /etc/cgred.conf
|
||||
OPTIONS="$NODAEMON $LOG"
|
||||
if [[ -n "$LOG_FILE" ]]; then
|
||||
OPTIONS="$OPTIONS --logfile=$LOG_FILE"
|
||||
fi
|
||||
if [[ -n "$SOCKET_USER" ]]; then
|
||||
OPTIONS="$OPTIONS -u $SOCKET_USER"
|
||||
fi
|
||||
if [[ -n "$SOCKET_GROUP" ]]; then
|
||||
OPTIONS="$OPTIONS -g $SOCKET_GROUP"
|
||||
fi
|
||||
else
|
||||
OPTIONS=""
|
||||
fi
|
||||
|
||||
# For convenience
|
||||
processname=cgrulesengd
|
||||
servicename=cgred
|
||||
lockfile="/var/lock/subsys/$servicename"
|
||||
pidfile=/var/run/cgred.pid
|
||||
|
||||
start()
|
||||
{
|
||||
echo -n $"Starting CGroup Rules Engine Daemon: "
|
||||
if [[ -f "$lockfile" ]]; then
|
||||
echo "$servicename is already running with PID $(cat ${pidfile})"
|
||||
return 0
|
||||
fi
|
||||
num=$(grep "cgroup" /proc/mounts | awk '$3=="cgroup"' | wc -l)
|
||||
if [[ "$num" -eq 0 ]]; then
|
||||
echo
|
||||
echo $"Cannot find cgroups, is cgconfig service running?"
|
||||
return 1
|
||||
fi
|
||||
daemon --check $servicename --pidfile $pidfile $CGRED_BIN $OPTIONS
|
||||
retval=$?
|
||||
echo
|
||||
if [[ $retval -ne 0 ]]; then
|
||||
return 7
|
||||
fi
|
||||
if ! touch "$lockfile"; then
|
||||
return 1
|
||||
fi
|
||||
pidof "$processname" > $pidfile
|
||||
return 0
|
||||
}
|
||||
|
||||
stop()
|
||||
{
|
||||
echo -n $"Stopping CGroup Rules Engine Daemon..."
|
||||
if [[ ! -f $pidfile ]]; then
|
||||
#log_success_msg
|
||||
return 0
|
||||
fi
|
||||
killproc -p $pidfile -TERM "$processname"
|
||||
retval=$?
|
||||
echo
|
||||
if [[ $retval -ne 0 ]]; then
|
||||
return 1
|
||||
fi
|
||||
rm -f "$lockfile" "$pidfile"
|
||||
return 0
|
||||
}
|
||||
|
||||
RETVAL=0
|
||||
|
||||
# See how we are called
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
RETVAL=$?
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
RETVAL=$?
|
||||
;;
|
||||
status)
|
||||
status -p $pidfile $servicename
|
||||
RETVAL=$?
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
RETVAL=$?
|
||||
;;
|
||||
condrestart)
|
||||
if [[ -f "$lockfile" ]]; then
|
||||
stop
|
||||
start
|
||||
RETVAL=$?
|
||||
fi
|
||||
;;
|
||||
reload|flash)
|
||||
if [[ -f "$lockfile" ]]; then
|
||||
echo $"Reloading rules configuration..."
|
||||
kill -s 12 "$(cat ${pidfile})"
|
||||
RETVAL=$?
|
||||
#if [[ $RETVAL -eq 0 ]] ; then
|
||||
# log_success_msg ""
|
||||
#else
|
||||
# log_failure_msg ""
|
||||
#fi
|
||||
else
|
||||
echo "$servicename is not running."
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
|
||||
RETVAL=2
|
||||
;;
|
||||
esac
|
||||
|
||||
exit $RETVAL
|
||||
43
etc/rc.d/rc.dnsmasq
Executable file
43
etc/rc.d/rc.dnsmasq
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/sh
|
||||
# Start/stop/restart dnsmasq (a small DNS/DHCP server):
|
||||
|
||||
# Start dnsmasq:
|
||||
dnsmasq_start() {
|
||||
if [ -x /usr/sbin/dnsmasq ]; then
|
||||
echo "Starting dnsmasq: /usr/sbin/dnsmasq"
|
||||
/usr/sbin/dnsmasq
|
||||
fi
|
||||
}
|
||||
|
||||
# Stop dnsmasq:
|
||||
dnsmasq_stop() {
|
||||
# Try to use the .pid file first:
|
||||
if pgrep -l -F /var/run/dnsmasq.pid 2> /dev/null | grep -q dnsmasq ; then
|
||||
echo "Stopping dnsmasq."
|
||||
pkill -F /var/run/dnsmasq.pid 2> /dev/null
|
||||
else # kill any dnsmasq processes in this namespace:
|
||||
echo "Stopping dnsmasq."
|
||||
killall --ns $$ dnsmasq 2> /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
# Restart dnsmasq:
|
||||
dnsmasq_restart() {
|
||||
dnsmasq_stop
|
||||
sleep 1
|
||||
dnsmasq_start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
dnsmasq_start
|
||||
;;
|
||||
'stop')
|
||||
dnsmasq_stop
|
||||
;;
|
||||
'restart')
|
||||
dnsmasq_restart
|
||||
;;
|
||||
*)
|
||||
echo "usage rc.dnsmasq: start|stop|restart"
|
||||
esac
|
||||
@@ -14,6 +14,7 @@ UNSHARE=/usr/bin/unshare
|
||||
SYSTEM=/sys/class/net
|
||||
CONF6=/proc/sys/net/ipv6/conf
|
||||
ACTIVE=$(ls --indicator-style=none $SYSTEM|awk '/^(bond|br|eth)[0-9]/' ORS=' ')
|
||||
NICS=$(ls --indicator-style=none $SYSTEM|awk '/^eth[0-9]+$/')
|
||||
|
||||
DOCKERD=dockerd
|
||||
DOCKER=/usr/bin/$DOCKERD
|
||||
@@ -33,11 +34,18 @@ TMP=/var/tmp/network.tmp
|
||||
|
||||
# Set defaults used by the docker daemon
|
||||
if [[ -f $DOCKER_CFG ]]; then
|
||||
if ! grep -qPm1 "_${PORT^^}(_[0-9]+)?=" $DOCKER_CFG; then
|
||||
# interface has changed, update configuration
|
||||
sed -ri "s/_(BR0|BOND0|ETH0)(_[0-9]+)?=/_${PORT^^}\2=/" $DOCKER_CFG
|
||||
sed -ri "s/(br0|bond0|eth0)(\.[0-9]+ )/$PORT\2/g" $DOCKER_CFG
|
||||
fi
|
||||
for NIC in $NICS; do
|
||||
if [[ -e $SYSTEM/${NIC/eth/br} ]]; then
|
||||
NIC=${NIC/eth/br}
|
||||
elif [[ -e $SYSTEM/${NIC/eth/bond} ]]; then
|
||||
NIC=${NIC/eth/bond}
|
||||
fi
|
||||
if ! grep -qPm1 "_${NIC^^}(_[0-9]+)?=" $DOCKER_CFG; then
|
||||
# interface has changed, update configuration
|
||||
X=${NIC//[^0-9]/}
|
||||
sed -ri "s/_(BR|BOND|ETH)$X(_[0-9]+)?=/_${NIC^^}\2=/; s/(br|bond|eth)$X(\.[0-9]+)? /$NIC\2 /g" $DOCKER_CFG
|
||||
fi
|
||||
done
|
||||
# Read (updated) unRAID docker configuration file
|
||||
. $DOCKER_CFG
|
||||
fi
|
||||
@@ -67,20 +75,16 @@ MTU=$(ip link show $PORT|grep -Po 'mtu \K\d+')
|
||||
[[ -n $MTU && $MTU -ne 1500 ]] && DOCKER_OPTS="--mtu=$MTU $DOCKER_OPTS"
|
||||
|
||||
# Enable IPv6 for docker bridge network
|
||||
if [[ -n $(ip -6 route show dev $PORT default) ]]; then
|
||||
if [[ -n $(ip -6 route show default dev $PORT) ]]; then
|
||||
DOCKER0='fd17::/64'
|
||||
DOCKER_OPTS="--ipv6 --fixed-cidr-v6=$DOCKER0 $DOCKER_OPTS"
|
||||
# create IPv6 NAT rule for docker0
|
||||
[[ -z $(ip6tables -t nat -S|grep -o "$DOCKER0") ]] && ip6tables -t nat -A POSTROUTING -s $DOCKER0 ! -o docker0 -j MASQUERADE
|
||||
else
|
||||
# ipv6 disabled
|
||||
[[ -e $SYSTEM/docker0 ]] && echo 1 > $CONF6/docker0/disable_ipv6
|
||||
[[ -d $CONF6/docker0 ]] && echo 1 > $CONF6/docker0/disable_ipv6
|
||||
fi
|
||||
|
||||
DETACH='ipvlan'
|
||||
ATTACH='macvlan'
|
||||
MODE='bridge'
|
||||
|
||||
export DOCKER_RAMDISK=true
|
||||
|
||||
# Get docker daemon PID (if existing)
|
||||
@@ -143,19 +147,39 @@ min6() {
|
||||
|
||||
wipe() {
|
||||
wet=($*)
|
||||
# remove temporary (privacy extensions) ipv6 addresses
|
||||
# remove temporary (privacy extensions) and host ipv6 addresses
|
||||
for tmp in $(ip -br -6 addr show scope global temporary dev $wet 2>/dev/null|awk '{$1=$2="";print}'); do
|
||||
for i in ${!wet[@]}; do
|
||||
[[ ${wet[$i]} == $tmp ]] && unset 'wet[i]'
|
||||
[[ ${wet[$i]} == $tmp || (${wet[$i]} =~ '::' && ${wet[$i]#*/} == 128) ]] && unset 'wet[i]'
|
||||
done
|
||||
done
|
||||
# return cleaned-up list without interface name
|
||||
echo ${wet[@]/$wet}
|
||||
}
|
||||
|
||||
# Network driver
|
||||
driver() {
|
||||
# user selection when bridge is enabled
|
||||
if [[ -z $DOCKER_NETWORK_TYPE ]]; then
|
||||
DETACH='ipvlan'
|
||||
ATTACH='macvlan'
|
||||
MODE='bridge'
|
||||
else
|
||||
DETACH='macvlan'
|
||||
ATTACH='ipvlan'
|
||||
MODE='l2 bridge'
|
||||
fi
|
||||
# fixed selection when bridge is disabled
|
||||
if [[ $1 != br ]]; then
|
||||
DETACH='ipvlan'
|
||||
ATTACH='macvlan'
|
||||
MODE='bridge'
|
||||
fi
|
||||
}
|
||||
|
||||
# Custom networks
|
||||
network(){
|
||||
docker network ls --filter driver="$1" --format='{{.Name}}' 2>/dev/null|tr '\n' ' '
|
||||
docker network ls --filter driver="$1" --format='{{.Name}}' 2>/dev/null|grep -P "^[a-z]+$2(\$|\.)"|tr '\n' ' '
|
||||
}
|
||||
|
||||
# Is container running?
|
||||
@@ -209,7 +233,7 @@ add_route(){
|
||||
# Add custom networks
|
||||
start_network(){
|
||||
# create list of possible custom networks
|
||||
EXCLUDE=; INCLUDE=$(ls --indicator-style=none $SYSTEM|awk '/^br[0-9]/' ORS=' ')
|
||||
EXCLUDE=; INCLUDE=$(ls --indicator-style=none $SYSTEM|awk '/^br[0-9]+/' ORS=' ')
|
||||
while IFS=$'\n' read -r NETWORK; do
|
||||
if [[ ${NETWORK:0:4} == bond ]]; then
|
||||
if [[ $INCLUDE =~ "${NETWORK/bond/br} " ]]; then
|
||||
@@ -225,7 +249,7 @@ start_network(){
|
||||
INCLUDE="${INCLUDE}${NETWORK} "
|
||||
fi
|
||||
fi
|
||||
done <<< $(ls --indicator-style=none $SYSTEM|grep -P '^(bond|eth)[0-9]')
|
||||
done <<< $(ls --indicator-style=none $SYSTEM|grep -P '^(bond|eth)[0-9]+')
|
||||
wait_daemon
|
||||
if ! is_docker_running; then return 1; fi
|
||||
# get container settings for custom networks to reconnect later
|
||||
@@ -237,16 +261,24 @@ start_network(){
|
||||
if [[ -n $XMLFILE ]]; then
|
||||
REBUILD=
|
||||
# update custom network reference (if changed)
|
||||
REF=$(grep -Pom1 '<Network>\K(br0|bond0|eth0)' $XMLFILE)
|
||||
if [[ -n $REF && $REF != $PORT ]]; then
|
||||
sed -ri "s/<Network>(br0|bond0|eth0)(\.[0-9]+)?<\/Network>/<Network>$PORT\2<\/Network>/" $XMLFILE
|
||||
# flag container for later rebuild
|
||||
REBUILD=1
|
||||
fi
|
||||
for NIC in $NICS; do
|
||||
if [[ -e $SYSTEM/${NIC/eth/br} ]]; then
|
||||
NIC=${NIC/eth/br}
|
||||
elif [[ -e $SYSTEM/${NIC/eth/bond} ]]; then
|
||||
NIC=${NIC/eth/bond}
|
||||
fi
|
||||
X=${NIC//[^0-9]/}
|
||||
REF=$(grep -Pom1 "<Network>\K(br|bond|eth)$X" $XMLFILE)
|
||||
if [[ -n $REF && $REF != $NIC ]]; then
|
||||
sed -ri "s/<Network>(br|bond|eth)$X(\.[0-9]+)?<\/Network>/<Network>$NIC\2<\/Network>/" $XMLFILE
|
||||
# flag container for later rebuild
|
||||
REBUILD=1
|
||||
fi
|
||||
done
|
||||
MY_NETWORK= MY_IP=
|
||||
while read_dom; do
|
||||
[[ $ENTITY == Network ]] && MY_NETWORK=$CONTENT
|
||||
[[ $ENTITY == MyIP ]] && MY_IP=${CONTENT// /,} && MY_IP=$(echo "$MY_IP" | tr -s "," ";")
|
||||
[[ $ENTITY == MyIP ]] && MY_IP=${CONTENT// /,} && MY_IP=$(echo "$MY_IP"|tr -s "," ";")
|
||||
done <$XMLFILE
|
||||
# only restore valid networks
|
||||
if [[ -n $MY_NETWORK ]]; then
|
||||
@@ -272,18 +304,27 @@ start_network(){
|
||||
done
|
||||
done
|
||||
# detach custom networks
|
||||
for NETWORK in $(network $DETACH); do
|
||||
[[ $STOCK =~ ${NETWORK%%[0-9]*} || $DOCKER_USER_NETWORKS != preserve ]] && docker network rm $NETWORK >/dev/null
|
||||
done
|
||||
# get existing custom networks
|
||||
for NETWORK in $(network $ATTACH); do
|
||||
if [[ $STOCK =~ ${NETWORK%%[0-9]*} ]]; then
|
||||
[[ $EXCLUDE =~ "$NETWORK " || ! $ACTIVE =~ "$NETWORK " ]] && docker network rm $NETWORK >/dev/null
|
||||
else
|
||||
[[ $DOCKER_USER_NETWORKS != preserve ]] && docker network rm $NETWORK >/dev/null
|
||||
for NIC in $NICS; do
|
||||
if [[ -e $SYSTEM/${NIC/eth/br} ]]; then
|
||||
NIC=${NIC/eth/br}
|
||||
elif [[ -e $SYSTEM/${NIC/eth/bond} ]]; then
|
||||
NIC=${NIC/eth/bond}
|
||||
fi
|
||||
X=${NIC//[^0-9]/}
|
||||
driver ${NIC//[0-9]/}
|
||||
for NETWORK in $(network $DETACH $X); do
|
||||
[[ $STOCK =~ ${NETWORK%%[0-9]*} || $DOCKER_USER_NETWORKS != preserve ]] && docker network rm $NETWORK >/dev/null
|
||||
done
|
||||
# get existing custom networks
|
||||
for NETWORK in $(network $ATTACH $X); do
|
||||
if [[ $STOCK =~ ${NETWORK%%[0-9]*} ]]; then
|
||||
[[ $EXCLUDE =~ "$NETWORK " || ! $ACTIVE =~ "$NETWORK " ]] && docker network rm $NETWORK >/dev/null
|
||||
else
|
||||
[[ $DOCKER_USER_NETWORKS != preserve ]] && docker network rm $NETWORK >/dev/null
|
||||
fi
|
||||
done
|
||||
NETWORKS=$(network $ATTACH $X)
|
||||
done
|
||||
NETWORKS=$(network $ATTACH)
|
||||
# add or remove custom network
|
||||
for NETWORK in $INCLUDE; do
|
||||
if [[ ! $DOCKER_CUSTOM_NETWORKS =~ "$NETWORK " ]]; then
|
||||
@@ -296,49 +337,27 @@ start_network(){
|
||||
fi
|
||||
# add auto defined networks
|
||||
SUBNET=; GATEWAY=; SERVER=; RANGE=;
|
||||
IPV4=$(ip -4 addr show $NETWORK|awk '/^ +inet /{print $2;exit}')
|
||||
if [[ -z $IPV4 ]]; then
|
||||
# wait for DHCP to assign IPv4 address
|
||||
KEY=${NETWORK%.*}
|
||||
KEY=${KEY/br/eth}
|
||||
KEY=${KEY/bond/eth}
|
||||
# get network configuration section
|
||||
sed -n "/^\[$KEY\]$/,/^\[/p" $INI >$TMP
|
||||
VLAN=${NETWORK#*.}
|
||||
if [[ -z $VLAN ]]; then
|
||||
USE_DHCP="USE_DHCP:0"
|
||||
else
|
||||
VLAN=$(grep -Pom1 "^VLANID:\d+=\"$VLAN\"$" $TMP)
|
||||
VLAN=${VLAN%=*}
|
||||
USE_DHCP=${VLAN/VLANID/USE_DHCP}
|
||||
fi
|
||||
# only wait when DHCP is used (max 10 seconds)
|
||||
[[ $(grep -Pom1 "^$USE_DHCP=.\K[^\"]+" $TMP) == yes ]] && LOOP=10 || LOOP=0
|
||||
while [[ -z $IPV4 && $LOOP -gt 0 ]]; do
|
||||
sleep 1
|
||||
IPV4=$(ip -4 addr show $NETWORK|awk '/^ +inet /{print $2;exit}')
|
||||
((LOOP--))
|
||||
done
|
||||
fi
|
||||
IPV4=$(ip -br -4 addr show $NETWORK|awk '{print $3;exit}')
|
||||
if [[ -n $IPV4 ]]; then
|
||||
SUBNET=$(ip -4 route show dev $NETWORK $IPV4|awk '{print $1;exit}')
|
||||
SUBNET=$(ip -4 route show $IPV4 dev $NETWORK|awk '{print $1;exit}')
|
||||
SERVER=${IPV4%/*}
|
||||
DHCP=${NETWORK/./_}
|
||||
DHCP=DOCKER_DHCP_${DHCP^^}
|
||||
RANGE=${!DHCP}
|
||||
GATEWAY=$(ip -4 route show dev $NETWORK default|awk '{print $3;exit}')
|
||||
GATEWAY=$(ip -4 route show default dev $NETWORK|awk '{print $3;exit}')
|
||||
fi
|
||||
SUBNET6=; GATEWAY6=; SERVER6=; RANGE6=;
|
||||
IPV6=$(min6 $(max6 $(wipe $(ip -br -6 addr show $NETWORK scope global|awk '{$2="";print;exit}'))|sort|head -1))
|
||||
if [[ -n $IPV6 ]]; then
|
||||
SUBNET6=$(ip -6 route show dev $NETWORK $IPV6|awk '{print $1;exit}')
|
||||
# get IPV6 subnet, preset to /64 if single host address is given
|
||||
[[ ${IPV6#*/} == 128 ]] && SUBNET6=$(echo $IPV6|sed -r 's/^([^:]+):([^:]+):([^:]+):([^:]+).*$/\1:\2:\3:\4::\/64/') || SUBNET6=$(ip -6 route show $IPV6 dev $NETWORK|awk '{print $1;exit}')
|
||||
SERVER6=${IPV6%/*}
|
||||
DHCP6=${NETWORK/./_}
|
||||
DHCP6=DOCKER_DHCP6_${DHCP6^^}
|
||||
RANGE6=${!DHCP6}
|
||||
GATEWAY6=$(ip -6 route show dev $NETWORK default|awk '{print $3;exit}')
|
||||
GATEWAY6=$(ip -6 route show default dev $NETWORK|awk '{print $3;exit}')
|
||||
# replace link local address for first address in subnet
|
||||
[[ ${GATEWAY6:0:4} == fe80 ]] && GATEWAY6=${SUBNET6%%/*}1
|
||||
[[ ${GATEWAY6:0:4} == fe80 ]] && GATEWAY6=${SUBNET6%/*}1
|
||||
fi
|
||||
else
|
||||
# add user defined networks
|
||||
@@ -401,21 +420,10 @@ start_network(){
|
||||
[[ -n $SUBNET6 && -n $RANGE6 ]] && RANGE6="--ip-range=$RANGE6" || RANGE6=;
|
||||
[[ -n $SUBNET6 ]] && SUBNET6="--ipv6 --subnet=$SUBNET6"
|
||||
if [[ -n $SUBNET || -n $SUBNET6 ]]; then
|
||||
SHIM_BASE=;
|
||||
# hack to let containers talk to host
|
||||
if [[ $DOCKER_ALLOW_ACCESS == yes && -n $IPV4 ]]; then
|
||||
BASE=${N4%/*}
|
||||
MASK=${N4#*/}
|
||||
IP=(${BASE//./ })
|
||||
IP=$(((${IP[0]}<<24)+(${IP[1]}<<16)+(${IP[2]}<<8)+${IP[3]}+2**(31-MASK)))
|
||||
SHIM_BASE=$BASE/$((MASK+1))
|
||||
SHIM_HIGH=$((IP>>24)).$((IP>>16&255)).$((IP>>8&255)).$((IP&255))/$((MASK+1))
|
||||
if [[ -z $SERVER ]]; then
|
||||
[[ -n $RANGE ]] && SERVER="--aux-address=server=${R4%/*}" || SERVER="--aux-address=server=${SHIM_HIGH%/*}"
|
||||
fi
|
||||
fi
|
||||
VHOST=vhost${NETWORK//[^0-9.]/}
|
||||
docker network create -d $ATTACH $SUBNET $GATEWAY $SERVER $RANGE $SUBNET6 $GATEWAY6 $SERVER6 $RANGE6 -o parent=$VHOST $NETWORK | xargs docker network inspect -f 'created network {{.Name}} with subnets: {{range .IPAM.Config}}{{.Subnet}}; {{end}}' 2>/dev/null | logger -t $(basename $0)
|
||||
TYPE=${NETWORK//[0-9.]/}
|
||||
driver $TYPE
|
||||
[[ $TYPE == br ]] && VHOST=$NETWORK || VHOST=vhost${NETWORK//[^0-9.]/}
|
||||
docker network create -d $ATTACH $SUBNET $GATEWAY $SERVER $RANGE $SUBNET6 $GATEWAY6 $SERVER6 $RANGE6 -o parent=$VHOST $NETWORK | xargs docker network inspect -f "created network $ATTACH {{.Name}} with subnets: {{range .IPAM.Config}}{{.Subnet}}; {{end}}" 2>/dev/null | logger -t $(basename $0)
|
||||
# connect containers to this new network
|
||||
for CONNECT in ${NETRESTORE[$NETWORK]}; do
|
||||
CONTAINER=${CONNECT%,*}
|
||||
@@ -427,65 +435,83 @@ start_network(){
|
||||
logger -t $(basename $0) "connecting $CONTAINER to network $NETWORK"
|
||||
docker network connect $MY_IP $NETWORK $CONTAINER >/dev/null
|
||||
if [[ -n ${CTRESTORE[$NETWORK]} ]]; then
|
||||
# rebuild the container before connecting to network
|
||||
# rebuild the container to use changed network
|
||||
logger -t $(basename $0) "rebuild container $CONTAINER"
|
||||
/usr/local/emhttp/plugins/dynamix.docker.manager/scripts/rebuild_container $CONTAINER
|
||||
fi
|
||||
done
|
||||
LINK=shim-$NETWORK
|
||||
# hack to let containers talk to host
|
||||
if [[ $DOCKER_ALLOW_ACCESS == yes && -n $IPV4 ]]; then
|
||||
if [[ ! -e $SYSTEM/$LINK && -n $SHIM_BASE ]]; then
|
||||
# create shim network
|
||||
ip link add $LINK link $NETWORK type $ATTACH mode $MODE
|
||||
if [[ $TYPE == br ]]; then
|
||||
LINK=shim-$NETWORK
|
||||
GW=($(ip -4 route show default dev $NETWORK|awk '{print $3,$5;exit}'))
|
||||
if [[ $DOCKER_ALLOW_ACCESS == yes && -n $IPV4 ]]; then
|
||||
# create shim interface and copy parent IPv4 address to shim interface
|
||||
[[ -e $SYSTEM/$LINK ]] || ip link add $LINK link $NETWORK type $ATTACH mode $MODE
|
||||
ip -4 addr flush dev $LINK
|
||||
ip -4 addr add $IPV4 dev $LINK metric 0
|
||||
# disable IPv6 on shim interface
|
||||
echo 1 > $CONF6/$LINK/disable_ipv6
|
||||
ip link set $LINK up
|
||||
if [[ -n $GW ]]; then
|
||||
if [[ -z ${GW[1]} ]]; then
|
||||
METRIC=1
|
||||
METRICS=$(ip -4 route show default|grep -Po 'metric \K\d+')
|
||||
while [[ " $METRICS " =~ " $METRIC " ]]; do ((METRIC++)); done
|
||||
# update existing route to avoid conflict with shim route
|
||||
ip -4 route del default via $GW dev $NETWORK
|
||||
ip -4 route add default via $GW dev $NETWORK metric $METRIC
|
||||
fi
|
||||
ip -4 route add default via $GW dev $LINK metric 0
|
||||
fi
|
||||
logger -t $(basename $0) "created network $LINK for host access"
|
||||
elif [[ -e $SYSTEM/$LINK ]]; then
|
||||
# remove shim interface
|
||||
[[ -n $GW ]] && ip -4 route del default via $GW dev $LINK
|
||||
ip -4 addr flush dev $LINK
|
||||
ip link set $LINK down
|
||||
ip link del $LINK
|
||||
fi
|
||||
else
|
||||
if [[ $DOCKER_ALLOW_ACCESS == yes && -n $IPV4 ]]; then
|
||||
ip -4 addr flush dev $VHOST
|
||||
# copy parent IPv4 address to vhost interface
|
||||
ip -4 addr add $IPV4 dev $VHOST metric 0
|
||||
logger -t $(basename $0) "prepared network $VHOST for host access"
|
||||
elif [[ -e $SYSTEM/$VHOST ]]; then
|
||||
# remove IP addresses
|
||||
ip -4 addr flush dev $VHOST
|
||||
fi
|
||||
[[ -n $SHIM_BASE ]] && shim_network ${SERVER##*=} $SHIM_BASE $SHIM_HIGH
|
||||
elif [[ -e $SYSTEM/$LINK ]]; then
|
||||
# remove shim network
|
||||
ip -4 addr flush dev $LINK
|
||||
ip -4 route flush dev $LINK
|
||||
ip link set $LINK down
|
||||
ip link del $LINK
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
# shim network creation
|
||||
shim_network(){
|
||||
ip -4 addr flush dev $LINK
|
||||
ip -4 addr add $1 dev $LINK
|
||||
ip -4 route flush dev $LINK
|
||||
ip -4 route add $2 src $1 dev $LINK
|
||||
ip -4 route add $3 src $1 dev $LINK
|
||||
DEFAULT=($(ip -4 route show dev $NETWORK default|awk '{print $3,$5}'))
|
||||
if [[ -n $DEFAULT ]]; then
|
||||
if [[ -z ${DEFAULT[1]} ]]; then
|
||||
METRIC=1
|
||||
METRICS=$(ip -4 route show default|grep -Po 'metric \K\d+')
|
||||
while [[ " $METRICS " =~ " $METRIC " ]]; do ((METRIC++)); done
|
||||
ip -4 route del default via $DEFAULT dev $NETWORK
|
||||
ip -4 route add default via $DEFAULT dev $NETWORK metric $METRIC
|
||||
fi
|
||||
ip -4 route add default via $DEFAULT dev $LINK metric 0
|
||||
fi
|
||||
}
|
||||
|
||||
# Remove custom networks
|
||||
stop_network(){
|
||||
for NETWORK in $(network $ATTACH); do
|
||||
[[ $STOCK =~ ${NETWORK%%[0-9]*} || $DOCKER_USER_NETWORKS != preserve ]] && docker network rm $NETWORK >/dev/null
|
||||
done
|
||||
for LINK in $(ls --indicator-style=none $SYSTEM|grep '^shim-'); do
|
||||
ip -4 addr flush dev $LINK
|
||||
ip -4 route flush dev $LINK
|
||||
ip -6 addr flush dev $LINK
|
||||
ip -6 route flush dev $LINK
|
||||
ip link set $LINK down
|
||||
ip link del $LINK
|
||||
for NIC in $NICS; do
|
||||
if [[ -e $SYSTEM/${NIC/eth/br} ]]; then
|
||||
NIC=${NIC/eth/br}
|
||||
elif [[ -e $SYSTEM/${NIC/eth/bond} ]]; then
|
||||
NIC=${NIC/eth/bond}
|
||||
fi
|
||||
driver ${NIC//[0-9]/}
|
||||
for NETWORK in $(network $ATTACH ${NIC//[^0-9]/}); do
|
||||
[[ $STOCK =~ ${NETWORK%%[0-9]*} || $DOCKER_USER_NETWORKS != preserve ]] && docker network rm $NETWORK >/dev/null
|
||||
TYPE=${NETWORK//[0-9.]/}
|
||||
if [[ $TYPE == br ]]; then
|
||||
LINK=shim-$NETWORK
|
||||
if [[ -e $SYSTEM/$LINK ]]; then
|
||||
GW=$(ip -4 route show default dev $LINK|awk '{print $3;exit}')
|
||||
[[ -n $GW ]] && ip -4 route del default via $GW dev $LINK
|
||||
ip addr flush dev $LINK
|
||||
ip link set $LINK down
|
||||
ip link del $LINK
|
||||
fi
|
||||
else
|
||||
VHOST=vhost${NETWORK//[^0-9.]/}
|
||||
[[ -e $SYSTEM/$VHOST ]] && ip addr flush dev $VHOST
|
||||
fi
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
@@ -593,7 +619,7 @@ restart)
|
||||
disown
|
||||
;;
|
||||
status)
|
||||
if is_docker_running; then
|
||||
if is_docker_running; then
|
||||
echo "status of $DOCKERD: running"
|
||||
echo "running containers:" $(running_containers)
|
||||
else
|
||||
|
||||
6
etc/rc.d/rc.font
Normal file
6
etc/rc.d/rc.font
Normal file
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This selects your default screen font from among the ones in
|
||||
# /usr/share/kbd/consolefonts.
|
||||
#
|
||||
setfont -v
|
||||
@@ -53,7 +53,8 @@
|
||||
# - added persistent option to dhcpcd
|
||||
|
||||
# Adapted by Bergware for use in unRAID - August 2023
|
||||
# - added macvlan network creation
|
||||
# - added macvtap network creation
|
||||
# - removed unnecessary error output redirection for 'run' command
|
||||
|
||||
############################
|
||||
# READ NETWORK CONFIG FILE #
|
||||
@@ -237,7 +238,7 @@ vlan_up(){
|
||||
VLAN=${VLANID[$i,$j]}
|
||||
run ip link add link $PORT name $PORT.$VLAN type vlan id $VLAN
|
||||
[[ ${PORT:0:3} == eth ]] && set_mtu $PORT.$VLAN
|
||||
run ip link set $PORT.$VLAN up 2>/dev/null
|
||||
run ip link set $PORT.$VLAN up
|
||||
done
|
||||
done
|
||||
}
|
||||
@@ -246,42 +247,43 @@ vlan_up(){
|
||||
vlan_down(){
|
||||
for PORT in ${BRNICS[$i]:-${IFNAME[$i]}}; do
|
||||
for VLAN in $(ls --indicator-style=none $SYSTEM|grep -Po "$PORT\.\d+"); do
|
||||
run ip link set $VLAN down 2>/dev/null
|
||||
run ip link del $VLAN 2>/dev/null
|
||||
run ip link set $VLAN down
|
||||
run ip link del $VLAN
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# function to create macvlan interfaces
|
||||
macvlan_up(){
|
||||
# function to create macvtap interfaces
|
||||
macvtap_up(){
|
||||
PARENT=${IFNAME[$i]}
|
||||
[[ -n ${BONDNICS[$i]} ]] && PARENT=${BONDNAME[$i]}
|
||||
[[ -n ${BRNICS[$i]} ]] && PARENT=${BRNAME[$i]}
|
||||
VHOST=vhost${PARENT//[^0-9]/}
|
||||
run ip link add link $PARENT name $VHOST type macvtap mode bridge
|
||||
set_mtu $VHOST
|
||||
run ip link set $VHOST up 2>/dev/null
|
||||
VTAP=vhost${PARENT//[^0-9]/}
|
||||
MAC=$(echo $(hostname)-$VTAP|md5sum|sed -r 's/^(..)(..)(..)(..)(..).*$/02:\1:\2:\3:\4:\5/')
|
||||
run ip link add link $PARENT name $VTAP address $MAC type macvtap mode bridge
|
||||
set_mtu $VTAP
|
||||
run ip link set $VTAP up
|
||||
for ((j=1;j<${VLANS[$i]:-0};j++)); do
|
||||
VLAN=${VLANID[$i,$j]}
|
||||
run ip link add link $PARENT.$VLAN name $VHOST.$VLAN type macvtap mode bridge
|
||||
set_mtu $VHOST.$VLAN
|
||||
run ip link set $VHOST.$VLAN up 2>/dev/null
|
||||
run ip link add link $PARENT.$VLAN name $VTAP.$VLAN address $MAC type macvtap mode bridge
|
||||
set_mtu $VTAP.$VLAN
|
||||
run ip link set $VTAP.$VLAN up
|
||||
done
|
||||
}
|
||||
|
||||
# function to delete macvlan interfaces
|
||||
macvlan_down(){
|
||||
# function to delete macvtap interfaces
|
||||
macvtap_down(){
|
||||
PARENT=${IFNAME[$i]}
|
||||
[[ -n ${BONDNICS[$i]} ]] && PARENT=${BONDNAME[$i]}
|
||||
[[ -n ${BRNICS[$i]} ]] && PARENT=${BRNAME[$i]}
|
||||
VHOST=vhost${PARENT//[^0-9]/}
|
||||
VTAP=vhost${PARENT//[^0-9]/}
|
||||
for ((j=1;j<${VLANS[$i]:-0};j++)); do
|
||||
VLAN=${VLANID[$i,$j]}
|
||||
run ip link set $VHOST.$VLAN down 2>/dev/null
|
||||
run ip link del $VHOST.$VLAN 2>/dev/null
|
||||
run ip addr flush dev $VTAP.$VLAN
|
||||
run ip link set $VTAP.$VLAN down
|
||||
run ip link del $VTAP.$VLAN
|
||||
done
|
||||
run ip link set $VHOST down 2>/dev/null
|
||||
run ip link del $VHOST 2>/dev/null
|
||||
run ip addr flush dev $VTAP
|
||||
run ip link set $VTAP down
|
||||
run ip link del $VTAP
|
||||
}
|
||||
|
||||
# function to enable/disable ipv6 protocol per interface
|
||||
@@ -305,8 +307,8 @@ ipv6_conf(){
|
||||
|
||||
# function to enable/disable ipv6 assignment per interface
|
||||
ipv6_addr(){
|
||||
ipv6_ra $IFACE $1 $2
|
||||
ipv6_ra vhost${IFACE//[^0-9.]} $1 $2
|
||||
[[ -d $CONF6/$IFACE ]] && ipv6_ra $IFACE $1 $2
|
||||
[[ -d $CONF6/$VHOST ]] && ipv6_ra $VHOST $1 $2
|
||||
# repeat action on related interfaces
|
||||
if [[ ${IFACE:0:4} == bond ]]; then
|
||||
ipv6_conf bond br eth $1 $2
|
||||
@@ -322,8 +324,8 @@ ipv6_addr(){
|
||||
ipaddr_up(){
|
||||
# disable IPv6 per interface when IPv4 only
|
||||
[[ $IP == ipv4 ]] && DISABLE6=1 || DISABLE6=0
|
||||
echo $DISABLE6 >$CONF6/$IFACE/disable_ipv6
|
||||
echo $DISABLE6 >$CONF6/vhost${IFACE//[^0-9.]}/disable_ipv6
|
||||
[[ -d $CONF6/$IFACE ]] && echo $DISABLE6 >$CONF6/$IFACE/disable_ipv6
|
||||
[[ -d $CONF6/$VHOST ]] && echo $DISABLE6 >$CONF6/$VHOST/disable_ipv6
|
||||
# repeat action on related interfaces
|
||||
if [[ ${IFACE:0:4} == bond ]]; then
|
||||
ipv6_up bond br eth $DISABLE6
|
||||
@@ -344,7 +346,7 @@ ipaddr_up(){
|
||||
[[ -n $DHCP_METRIC && $DHCP_METRIC -gt 0 ]] && DHCP_OPTIONS="$DHCP_OPTIONS -m $DHCP_METRIC"
|
||||
[[ $IP == ipv4 ]] && DHCP_OPTIONS="$DHCP_OPTIONS -4"
|
||||
[[ $IP == ipv6 ]] && DHCP_OPTIONS="$DHCP_OPTIONS -6"
|
||||
[[ $IP != ipv4 && -n $PRIV6 ]] && echo $PRIV6 >$CONF6/$IFACE/use_tempaddr
|
||||
[[ $IP != ipv4 && -n $PRIV6 && -d $CONF6/$IFACE ]] && echo $PRIV6 >$CONF6/$IFACE/use_tempaddr
|
||||
log "polling up to 60 sec for DHCP server on interface $IFACE"
|
||||
if ! run timeout 60 dhcpcd -w $DHCP_OPTIONS $IFACE; then
|
||||
log "can't obtain IP address, continue polling in background on interface $IFACE"
|
||||
@@ -358,15 +360,15 @@ ipaddr_up(){
|
||||
[[ $j -eq 0 ]] && ADDR=${IPADDR[$i]} || ADDR=${IPADDR[$i,$j]}
|
||||
if [[ -n $ADDR ]]; then
|
||||
[[ $j -eq 0 ]] && MASK=${NETMASK[$i]} || MASK=${NETMASK[$i,$j]}
|
||||
[[ -n $MASK ]] && run ip -4 addr add $ADDR/$MASK dev $IFACE
|
||||
[[ -n $MASK ]] && run ip -4 addr add $ADDR/$MASK dev $IFACE metric 1
|
||||
fi
|
||||
fi
|
||||
if [[ $IP != ipv4 ]]; then
|
||||
[[ $j -eq 0 ]] && ADDR6=${IPADDR6[$i]} || ADDR6=${IPADDR6[$i,$j]}
|
||||
if [[ -n $ADDR6 ]]; then
|
||||
[[ $j -eq 0 ]] && MASK6=${NETMASK6[$i]} || MASK6=${NETMASK6[$i,$j]}
|
||||
[[ -n $MASK6 ]] && run ip -6 addr add $ADDR6/$MASK6 dev $IFACE
|
||||
[[ -n $PRIV6 ]] && echo 0 >$CONF6/$IFACE/use_tempaddr
|
||||
[[ -n $MASK6 ]] && run ip -6 addr add $ADDR6/$MASK6 dev $IFACE metric 1
|
||||
[[ -n $PRIV6 && -d $CONF6/$IFACE ]] && echo 0 >$CONF6/$IFACE/use_tempaddr
|
||||
fi
|
||||
fi
|
||||
else
|
||||
@@ -392,7 +394,7 @@ ipaddr_conf(){
|
||||
ipaddr_flush(){
|
||||
run ip -$1 addr flush dev $IFACE
|
||||
run ip -$1 route flush dev $IFACE
|
||||
run ip -$1 addr flush dev vhost${IFACE//[^0-9.]}
|
||||
[[ -e $SYSTEM/$VHOST ]] && run ip -$1 addr flush dev $VHOST
|
||||
if [[ ${IFACE:0:4} == bond ]]; then
|
||||
ipaddr_conf bond br eth $1
|
||||
elif [[ ${IFACE:0:2} == br ]]; then
|
||||
@@ -410,7 +412,7 @@ ipaddr_down(){
|
||||
[[ $IP == ipv4 ]] && DHCP_OPTIONS="$DHCP_OPTIONS -4"
|
||||
[[ $IP == ipv6 ]] && DHCP_OPTIONS="$DHCP_OPTIONS -6"
|
||||
# release DHCP assigned addresses
|
||||
run dhcpcd $DHCP_OPTIONS $IFACE 2>/dev/null
|
||||
run dhcpcd $DHCP_OPTIONS $IFACE
|
||||
sleep 1
|
||||
fi
|
||||
# release assigned addresses and routes
|
||||
@@ -431,7 +433,7 @@ if_up(){
|
||||
[[ -n ${BONDNICS[$i]} ]] && bond_up # create interface as bond
|
||||
[[ -n ${VLANS[$i]} ]] && vlan_up # create interface VLANs
|
||||
[[ -n ${BRNICS[$i]} ]] && br_up # create interface as bridge
|
||||
macvlan_up # create macvlan interfaces
|
||||
[[ -z ${BRNICS[$i]} ]] && macvtap_up # create macvtap interfaces
|
||||
# if the interface isn't in the kernel yet
|
||||
# but there's an alias for it in modules.conf
|
||||
# then it should be loaded first
|
||||
@@ -451,6 +453,8 @@ if_up(){
|
||||
[[ $DEBUG_ETH_UP == yes ]] && log "interface $IFACE does not exist (yet)"
|
||||
continue
|
||||
fi
|
||||
# macvtap interface name
|
||||
VHOST=vhost${IFACE//[^0-9.]}
|
||||
# set main interface
|
||||
if [[ $j -eq 0 ]]; then
|
||||
# set hardware address before interface goes up
|
||||
@@ -504,6 +508,8 @@ if_down(){
|
||||
for ((j=0;j<${VLANS[$i]:-1};j++)); do
|
||||
[[ $j -eq 0 ]] && IFACE=$1 || IFACE=$1.${VLANID[$i,$j]}
|
||||
[[ $j -eq 0 ]] && IP=${PROTOCOL[$i]:-ipv4} || IP=${PROTOCOL[$i,$j]:-ipv4}
|
||||
# macvtap interface name
|
||||
VHOST=vhost${IFACE//[^0-9.]}
|
||||
if [[ -e $SYSTEM/$IFACE ]]; then
|
||||
# take down interface
|
||||
if [[ $IP == ipv4 ]]; then
|
||||
@@ -530,7 +536,7 @@ if_down(){
|
||||
[[ $DEBUG_ETH_UP == yes ]] && log "interface $IFACE not present, can't take down"
|
||||
fi
|
||||
done
|
||||
macvlan_down # delete macvlan interfaces
|
||||
[[ -z ${BRNICS[$i]} ]] && macvtap_down # delete macvtap interfaces
|
||||
[[ -n ${BRNICS[$i]} ]] && br_down # delete interface as bridge
|
||||
[[ -n ${VLANS[$i]} ]] && vlan_down # delete interface VLANs
|
||||
[[ -n ${BONDNICS[$i]} ]] && bond_down # delete interface as bond
|
||||
|
||||
36
etc/rc.d/rc.inetd
Executable file
36
etc/rc.d/rc.inetd
Executable file
@@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
# Start/stop/restart inetd, the BSD Internet super-daemon.
|
||||
|
||||
# Start inetd:
|
||||
inetd_start() {
|
||||
if [ -x /usr/sbin/inetd ]; then
|
||||
echo "Starting Internet super-server daemon: /usr/sbin/inetd"
|
||||
/usr/sbin/inetd
|
||||
fi
|
||||
}
|
||||
|
||||
# Stop inetd:
|
||||
inetd_stop() {
|
||||
killall inetd
|
||||
}
|
||||
|
||||
# Restart inetd:
|
||||
inetd_restart() {
|
||||
inetd_stop
|
||||
sleep 1
|
||||
inetd_start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
inetd_start
|
||||
;;
|
||||
'stop')
|
||||
inetd_stop
|
||||
;;
|
||||
'restart')
|
||||
inetd_restart
|
||||
;;
|
||||
*)
|
||||
echo "usage $0 start|stop|restart"
|
||||
esac
|
||||
100
etc/rc.d/rc.ip_forward
Executable file
100
etc/rc.d/rc.ip_forward
Executable file
@@ -0,0 +1,100 @@
|
||||
#!/bin/sh
|
||||
# /etc/rc.d/rc.ip_forward: start/stop IP packet forwarding
|
||||
#
|
||||
# If you intend to run your Linux box as a router, i.e. as a
|
||||
# computer that forwards and redistributes network packets, you
|
||||
# will need to enable IP packet forwarding in your kernel.
|
||||
#
|
||||
# To activate IP packet forwarding at boot time, make this
|
||||
# script executable: chmod 755 /etc/rc.d/rc.ip_forward
|
||||
#
|
||||
# To disable IP packet forwarding at boot time, make this
|
||||
# script non-executable: chmod 644 /etc/rc.d/rc.ip_forward
|
||||
|
||||
# Start IP packet forwarding:
|
||||
ip_forward_start() {
|
||||
if [ -f /proc/sys/net/ipv4/ip_forward ]; then
|
||||
echo "Activating IPv4 packet forwarding."
|
||||
echo 1 > /proc/sys/net/ipv4/ip_forward
|
||||
# Changing /proc/sys/net/ipv4/ip_forward results in resetting all
|
||||
# non-default ipv4 parameters for the interface as mentioned in
|
||||
# /usr/src/linux/Documentation/networking/ip-sysctl.txt. So, we
|
||||
# will reapply any ipv4 sysctl parameters now:
|
||||
if [ -r /etc/sysctl.conf ]; then
|
||||
/bin/grep ipv4 /etc/sysctl.conf | sysctl -p - 1> /dev/null 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
if [ -f /proc/sys/net/ipv6/conf/all/forwarding ]; then
|
||||
echo "Activating IPv6 packet forwarding."
|
||||
echo 1 > /proc/sys/net/ipv6/conf/all/forwarding
|
||||
# Changing /proc/sys/net/ipv6/conf/all/forwarding results in resetting
|
||||
# all non-default ipv6 parameters for the interface as mentioned in
|
||||
# /usr/src/linux/Documentation/networking/ip-sysctl.txt. So, we
|
||||
# will reapply any ipv6 sysctl parameters now:
|
||||
if [ -r /etc/sysctl.conf ]; then
|
||||
/bin/grep ipv6 /etc/sysctl.conf | sysctl -p - 1> /dev/null 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
# When using IPv4 packet forwarding, you will also get the
|
||||
# rp_filter, which automatically rejects incoming packets if the
|
||||
# routing table entry for their source address doesn't match the
|
||||
# network interface they're arriving on. This has security
|
||||
# advantages because it prevents the so-called IP spoofing,
|
||||
# however it can pose problems if you use asymmetric routing
|
||||
# (packets from you to a host take a different path than packets
|
||||
# from that host to you) or if you operate a non-routing host
|
||||
# which has several IP addresses on different interfaces. To
|
||||
# turn rp_filter off, uncomment the lines below:
|
||||
#if [ -r /proc/sys/net/ipv4/conf/all/rp_filter ]; then
|
||||
# echo "Disabling rp_filter."
|
||||
# echo 0 > /proc/sys/net/ipv4/conf/all/rp_filter
|
||||
#fi
|
||||
}
|
||||
|
||||
# Stop IP packet forwarding:
|
||||
ip_forward_stop() {
|
||||
if [ -f /proc/sys/net/ipv4/ip_forward ]; then
|
||||
echo "Disabling IPv4 packet forwarding."
|
||||
echo 0 > /proc/sys/net/ipv4/ip_forward
|
||||
# Changing /proc/sys/net/ipv4/ip_forward results in resetting all
|
||||
# non-default ipv4 parameters for the interface as mentioned in
|
||||
# /usr/src/linux/Documentation/networking/ip-sysctl.txt. So, we
|
||||
# will reapply any ipv4 sysctl parameters now:
|
||||
if [ -r /etc/sysctl.conf ]; then
|
||||
/bin/grep ipv4 /etc/sysctl.conf | sysctl -p - 1> /dev/null 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
if [ -f /proc/sys/net/ipv6/conf/all/forwarding ]; then
|
||||
echo "Disabling IPv6 packet forwarding."
|
||||
echo 0 > /proc/sys/net/ipv6/conf/all/forwarding
|
||||
# Changing /proc/sys/net/ipv6/conf/all/forwarding results in resetting
|
||||
# all non-default ipv6 parameters for the interface as mentioned in
|
||||
# /usr/src/linux/Documentation/networking/ip-sysctl.txt. So, we
|
||||
# will reapply any ipv6 sysctl parameters now:
|
||||
if [ -r /etc/sysctl.conf ]; then
|
||||
/bin/grep ipv6 /etc/sysctl.conf | sysctl -p - 1> /dev/null 2> /dev/null
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Restart IP packet forwarding:
|
||||
ip_forward_restart() {
|
||||
ip_forward_stop
|
||||
sleep 1
|
||||
ip_forward_start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
ip_forward_start
|
||||
;;
|
||||
'stop')
|
||||
ip_forward_stop
|
||||
;;
|
||||
'restart')
|
||||
ip_forward_restart
|
||||
;;
|
||||
*)
|
||||
echo "usage $0 start|stop|restart"
|
||||
esac
|
||||
|
||||
40
etc/rc.d/rc.kadmind
Normal file
40
etc/rc.d/rc.kadmind
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/bin/sh
|
||||
# Start the Kerberos administration server. This typically runs on the
|
||||
# master Kerberos server, which stores the KDC database.
|
||||
|
||||
# To change the default options, edit /etc/default/kadmind.
|
||||
if [ -r /etc/default/kadmind ]; then
|
||||
. /etc/default/kadmind
|
||||
fi
|
||||
|
||||
start_atd() {
|
||||
if ! /usr/bin/pgrep --ns $$ --euid root -f "^/usr/sbin/kadmind" 1> /dev/null 2> /dev/null ; then
|
||||
echo "Starting kadmind: /usr/sbin/kadmind $KADMIND_OPTIONS"
|
||||
/usr/sbin/kadmind $KADMIND_OPTIONS
|
||||
fi
|
||||
}
|
||||
|
||||
stop_atd() {
|
||||
echo "Stopping kadmind."
|
||||
/usr/bin/pkill --ns $$ --euid root -f "^/usr/sbin/kadmind" 2> /dev/null
|
||||
}
|
||||
|
||||
restart_atd() {
|
||||
stop_atd
|
||||
sleep 1
|
||||
start_atd
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
start_atd
|
||||
;;
|
||||
'stop')
|
||||
stop_atd
|
||||
;;
|
||||
'restart')
|
||||
restart_atd
|
||||
;;
|
||||
*)
|
||||
echo "usage $0 start|stop|restart"
|
||||
esac
|
||||
41
etc/rc.d/rc.kpropd
Normal file
41
etc/rc.d/rc.kpropd
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
# Start the Kerberos V5 slave KDC update server. This runs on a slave
|
||||
# (secondary) KDC server. It allows the master Kerberos server to use
|
||||
# kprop(8) to propagate its database to the slave servers.
|
||||
|
||||
# To change the default options, edit /etc/default/kpropd.
|
||||
if [ -r /etc/default/kpropd ]; then
|
||||
. /etc/default/kpropd
|
||||
fi
|
||||
|
||||
start_atd() {
|
||||
if ! /usr/bin/pgrep --ns $$ --euid root -f "^/usr/sbin/kpropd" 1> /dev/null 2> /dev/null ; then
|
||||
echo "Starting kpropd: /usr/sbin/kpropd $KPROPD_OPTIONS"
|
||||
/usr/sbin/kpropd $KPROPD_OPTIONS
|
||||
fi
|
||||
}
|
||||
|
||||
stop_atd() {
|
||||
echo "Stopping kpropd."
|
||||
/usr/bin/pkill --ns $$ --euid root -f "^/usr/sbin/kpropd" 2> /dev/null
|
||||
}
|
||||
|
||||
restart_atd() {
|
||||
stop_atd
|
||||
sleep 1
|
||||
start_atd
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
start_atd
|
||||
;;
|
||||
'stop')
|
||||
stop_atd
|
||||
;;
|
||||
'restart')
|
||||
restart_atd
|
||||
;;
|
||||
*)
|
||||
echo "usage $0 start|stop|restart"
|
||||
esac
|
||||
41
etc/rc.d/rc.krb5kdc
Normal file
41
etc/rc.d/rc.krb5kdc
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
# Start krb5kdc, which is the Kerberos version 5 Authentication Service
|
||||
# and Key Distribution Center (AS/KDC). This needs to run first on both
|
||||
# master and secondary KDCs.
|
||||
|
||||
# To change the default options, edit /etc/default/krb5kdc.
|
||||
if [ -r /etc/default/krb5kdc ]; then
|
||||
. /etc/default/krb5kdc
|
||||
fi
|
||||
|
||||
start_atd() {
|
||||
if ! /usr/bin/pgrep --ns $$ --euid root -f "^/usr/sbin/krb5kdc" 1> /dev/null 2> /dev/null ; then
|
||||
echo "Starting krb5kdc: /usr/sbin/krb5kdc $KRB5KDC_OPTIONS"
|
||||
/usr/sbin/krb5kdc $KRB5KDC_OPTIONS
|
||||
fi
|
||||
}
|
||||
|
||||
stop_atd() {
|
||||
echo "Stopping krb5kdc."
|
||||
/usr/bin/pkill --ns $$ --euid root -f "^/usr/sbin/krb5kdc" 2> /dev/null
|
||||
}
|
||||
|
||||
restart_atd() {
|
||||
stop_atd
|
||||
sleep 1
|
||||
start_atd
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
start_atd
|
||||
;;
|
||||
'stop')
|
||||
stop_atd
|
||||
;;
|
||||
'restart')
|
||||
restart_atd
|
||||
;;
|
||||
*)
|
||||
echo "usage $0 start|stop|restart"
|
||||
esac
|
||||
@@ -89,10 +89,10 @@ min6() {
|
||||
|
||||
wipe() {
|
||||
wet=($*)
|
||||
# remove temporary (privacy extensions) ipv6 addresses
|
||||
# remove temporary (privacy extensions) and host ipv6 addresses
|
||||
for tmp in $(ip -br -6 addr show scope global temporary dev $wet 2>/dev/null|awk '{$1=$2="";print}'); do
|
||||
for i in ${!wet[@]}; do
|
||||
[[ ${wet[$i]} == $tmp ]] && unset 'wet[i]'
|
||||
[[ ${wet[$i]} == $tmp || (${wet[$i]} =~ '::' && ${wet[$i]#*/} == 128) ]] && unset 'wet[i]'
|
||||
done
|
||||
done
|
||||
# return cleaned-up list without interface name
|
||||
|
||||
@@ -20,6 +20,7 @@ if [ -f /boot/config/domain.cfg ]; then
|
||||
. /boot/config/domain.cfg
|
||||
fi
|
||||
|
||||
SYSTEM=/sys/class/net
|
||||
MODULES=${MODULES:-"vhost_net"}
|
||||
TIMEOUT=${TIMEOUT:-60}
|
||||
HOSTSHUTDOWN=${HOSTSHUTDOWN:-"shutdown"}
|
||||
@@ -158,8 +159,12 @@ waitstop() {
|
||||
return 1
|
||||
}
|
||||
|
||||
version() {
|
||||
echo $1 | awk -F. '{printf("%03d%03d", $1,$2);}'
|
||||
}
|
||||
|
||||
start_libvirtd() {
|
||||
if [ -f $LIBVIRTD_PIDFILE ];then
|
||||
if [[ -f $LIBVIRTD_PIDFILE ]]; then
|
||||
echo "libvirt is already running..."
|
||||
exit 1
|
||||
fi
|
||||
@@ -171,14 +176,34 @@ start_libvirtd() {
|
||||
sed -ri "s/<vendor id='none'\/>/<vendor_id state='on' value='none'\/>/g" /etc/libvirt/qemu/*.xml &> /dev/null
|
||||
# remove <locked/> from xml because libvirt + virlogd + virlockd has an issue with locked
|
||||
sed -ri "s/<locked\/>//g" /etc/libvirt/qemu/*.xml &> /dev/null
|
||||
# update interface section of VM configuration files
|
||||
if [[ -f /boot/config/network.cfg && -z $(grep -Po '^BRNICS\[0\]="\K[^"]+' /boot/config/network.cfg) ]]; then
|
||||
# bridge interface to macvlan interface
|
||||
sed -ri "s/<interface type='bridge'>/<interface type='direct'>/;s/<source bridge='br([0-9]+(.[0-9]+)?)'\/>/<source dev='vhost\1' mode='bridge'\/>/" /etc/libvirt/qemu/*.xml &> /dev/null
|
||||
else
|
||||
# macvlan interface to bridge interface
|
||||
sed -ri "s/<interface type='direct'>/<interface type='bridge'>/;s/<source dev='vhost([0-9]+(.[0-9]+)?)' mode='bridge'\/>/<source bridge='br\1'\/>/" /etc/libvirt/qemu/*.xml &> /dev/null
|
||||
# Remove "<watchdog model='itco' action='reset'/>" if reverting from later release.
|
||||
. /etc/unraid-version
|
||||
if [[ $(version $version) -le $(version "6.12") ]]; then
|
||||
sed -ri "/<watchdog model='itco' action='reset'\/>/d" /etc/libvirt/qemu/*.xml &> /dev/null
|
||||
fi
|
||||
# update interface section((s) of VM configuration files
|
||||
for XML in /etc/libvirt/qemu/*.xml; do
|
||||
# get all interface sections
|
||||
ROW=($(grep -nhP '<interface type=' "$XML"|grep -Pom1 '^[0-9]+'))
|
||||
# get all source sections
|
||||
CAT=($(grep -nhP '<source (bridge|dev)=' "$XML"|awk '{print $1$3}'))
|
||||
for i in ${!ROW[@]}; do
|
||||
ROW2=$(echo ${CAT[$i]}|grep -Pom1 '^[0-9]+')
|
||||
DEV=$(echo ${CAT[$i]}|grep -Pom1 "^.+='\K[^']+")
|
||||
if [[ ! -e $SYSTEM/$DEV ]]; then
|
||||
NAME=${DEV//[0-9.]/}
|
||||
if [[ $NAME == br ]]; then
|
||||
# change to macvtap
|
||||
logger -t $(basename $0) "change $DEV to macvtap in $XML"
|
||||
sed -ri "${ROW[$i]} s/<interface type='bridge'>/<interface type='direct' trustGuestRxFilters='yes'>/; $ROW2 s/<source bridge='$DEV'\/>/<source dev='${DEV/$NAME/vhost}' mode='bridge'\/>/" "$XML"
|
||||
else
|
||||
# change to bridge
|
||||
logger -t $(basename $0) "change $DEV to bridge in $XML"
|
||||
sed -ri "${ROW[$i]} s/<interface type='direct'( trustGuestRxFilters='yes')?>/<interface type='bridge'>/; $ROW2 s/<source dev='$DEV' mode='bridge'\/>/<source bridge='${DEV/$NAME/br}'\/>/" "$XML"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
done
|
||||
# copy any new conf files we dont currently have
|
||||
cp -n /etc/libvirt-/*.conf /etc/libvirt &> /dev/null
|
||||
# ensure tpm-states path exists
|
||||
@@ -191,7 +216,7 @@ start_libvirtd() {
|
||||
}
|
||||
|
||||
stop_libvirtd() {
|
||||
if [ ! -f $LIBVIRTD_PIDFILE ];then
|
||||
if [[ ! -f $LIBVIRTD_PIDFILE ]]; then
|
||||
echo "libvirt is not running..."
|
||||
exit 2
|
||||
fi
|
||||
@@ -207,7 +232,7 @@ stop_libvirtd() {
|
||||
}
|
||||
|
||||
start_virtlogd() {
|
||||
if [ -f $VIRTLOGD_PIDFILE ];then
|
||||
if [[ -f $VIRTLOGD_PIDFILE ]]; then
|
||||
echo "virtlogd is already running..."
|
||||
exit 1
|
||||
fi
|
||||
@@ -217,7 +242,7 @@ start_virtlogd() {
|
||||
}
|
||||
|
||||
stop_virtlogd() {
|
||||
if [ ! -f $VIRTLOGD_PIDFILE ];then
|
||||
if [[ ! -f $VIRTLOGD_PIDFILE ]]; then
|
||||
echo "virtlogd is not running..."
|
||||
exit 2
|
||||
fi
|
||||
@@ -227,7 +252,7 @@ stop_virtlogd() {
|
||||
}
|
||||
|
||||
start_virtlockd() {
|
||||
if [ -f $VIRTLOCKD_PIDFILE ];then
|
||||
if [[ -f $VIRTLOCKD_PIDFILE ]]; then
|
||||
echo "virtlockd is already running..."
|
||||
exit 1
|
||||
fi
|
||||
@@ -237,7 +262,7 @@ start_virtlockd() {
|
||||
}
|
||||
|
||||
stop_virtlockd() {
|
||||
if [ ! -f $VIRTLOCKD_PIDFILE ];then
|
||||
if [[ ! -f $VIRTLOCKD_PIDFILE ]]; then
|
||||
echo "virtlockd is not running..."
|
||||
exit 2
|
||||
fi
|
||||
|
||||
11
etc/rc.d/rc.loop
Executable file
11
etc/rc.d/rc.loop
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Load the loop device kernel module.
|
||||
#
|
||||
|
||||
if modinfo loop 1> /dev/null 2> /dev/null ; then
|
||||
if ! lsmod | grep -wq "^loop" ; then
|
||||
modprobe loop
|
||||
fi
|
||||
fi
|
||||
|
||||
81
etc/rc.d/rc.messagebus
Executable file
81
etc/rc.d/rc.messagebus
Executable file
@@ -0,0 +1,81 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# messagebus: The D-BUS systemwide message bus
|
||||
#
|
||||
# description: This is a daemon which broadcasts notifications of system events \
|
||||
# and other messages. See http://www.freedesktop.org/software/dbus/
|
||||
#
|
||||
# processname: dbus-daemon
|
||||
|
||||
# This is a modified version of the rc.messagebus script distributed with the
|
||||
# dbus sources. Thanks to Don Tanner of the GWare <http://gware.org> Project
|
||||
# for most of the work involved --Robby Workman <rworkman@slackware.com>
|
||||
|
||||
|
||||
PIDFILE=/var/run/dbus/dbus.pid
|
||||
|
||||
start() {
|
||||
mkdir -p $(dirname $PIDFILE)
|
||||
if ! ps -u messagebus -c | grep -wq dbus-daemon; then
|
||||
rm -f $(dirname $PIDFILE)/*
|
||||
if [ -x /usr/bin/dbus-uuidgen -a -x /usr/bin/dbus-daemon ] ; then
|
||||
echo "Starting system message bus: /usr/bin/dbus-uuidgen --ensure ; /usr/bin/dbus-daemon --system"
|
||||
/usr/bin/dbus-uuidgen --ensure
|
||||
/usr/bin/dbus-daemon --system 1> /dev/null
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
if [ -e "$PIDFILE" ]; then
|
||||
echo "Stopping system message bus..."
|
||||
pid=$(cat $PIDFILE)
|
||||
kill $pid 1> /dev/null 2> /dev/null
|
||||
# Just in case:
|
||||
killall dbus-daemon 1> /dev/null 2> /dev/null
|
||||
rm -f $PIDFILE
|
||||
fi
|
||||
}
|
||||
|
||||
reload() {
|
||||
echo "Reloading system message bus configuration..."
|
||||
if [ -e "$PIDFILE" ]; then
|
||||
pid=$(cat $PIDFILE)
|
||||
kill -HUP $pid
|
||||
else
|
||||
killall -HUP dbus-daemon
|
||||
fi
|
||||
}
|
||||
|
||||
status() {
|
||||
if ps -u messagebus -c | grep -wq dbus-daemon; then
|
||||
echo "System dbus-daemon is running."
|
||||
else
|
||||
echo "System dbus-daemon is stopped."
|
||||
fi
|
||||
}
|
||||
|
||||
# See how we were called.
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
stop
|
||||
start
|
||||
echo "You may need to restart your Window Manager to reconnect to the system dbus."
|
||||
;;
|
||||
reload)
|
||||
reload
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|restart|reload|status}"
|
||||
;;
|
||||
esac
|
||||
|
||||
45
etc/rc.d/rc.saslauthd
Normal file
45
etc/rc.d/rc.saslauthd
Normal file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
# rc.saslauthd: start/stop/restart saslauthd
|
||||
#
|
||||
# saslauthd is a daemon process that handles plaintext authentication
|
||||
# requests on behalf of the SASL library. The CMU Cyrus SASL library
|
||||
# is a general purpose authentication library for server and client
|
||||
# applications. It is mostly used to authenticate to mail servers.
|
||||
#
|
||||
# saslauthd should be started from the system boot scripts when going
|
||||
# to multi-user mode. When running against a protected authentication
|
||||
# database (e.g. the shadow mechanism), it must be run as the superuser.
|
||||
#
|
||||
|
||||
saslauthd_start() {
|
||||
# If saslauthd is not running, start it:
|
||||
if [ ! -r /var/state/saslauthd/saslauthd.pid ]; then
|
||||
# Use PAM authentication with credential caching:
|
||||
echo "Starting SASL authentication daemon: /usr/sbin/saslauthd -a pam -c"
|
||||
/usr/sbin/saslauthd -a pam -c
|
||||
fi
|
||||
}
|
||||
|
||||
saslauthd_stop() {
|
||||
kill `cat /var/state/saslauthd/saslauthd.pid 2> /dev/null` 2> /dev/null
|
||||
sleep 1
|
||||
}
|
||||
|
||||
saslauthd_restart() {
|
||||
saslauthd_stop
|
||||
saslauthd_start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
saslauthd_start
|
||||
;;
|
||||
'stop')
|
||||
saslauthd_stop
|
||||
;;
|
||||
'restart')
|
||||
saslauthd_restart
|
||||
;;
|
||||
*)
|
||||
echo "usage $0 start|stop|restart"
|
||||
esac
|
||||
132
etc/rc.d/rc.serial
Executable file
132
etc/rc.d/rc.serial
Executable file
@@ -0,0 +1,132 @@
|
||||
#
|
||||
# /etc/rc.serial
|
||||
# Initializes the serial ports on your system
|
||||
#
|
||||
# chkconfig: 2345 50 75
|
||||
# description: This initializes the settings of the serial port
|
||||
#
|
||||
# FILE_VERSION: 19981128
|
||||
#
|
||||
# Distributed with setserial and the serial driver. We need to use the
|
||||
# FILE_VERSION field to assure that we don't overwrite a newer rc.serial
|
||||
# file with a newer one.
|
||||
#
|
||||
# XXXX For now, the autosave feature doesn't work if you are
|
||||
# using the multiport feature; it doesn't save the multiport configuration
|
||||
# (for now). Autosave also doesn't work for the hayes devices.
|
||||
#
|
||||
|
||||
RCLOCKFILE=/var/lock/subsys/serial
|
||||
DIRS="/lib/modules/`uname -r`/misc /lib/modules /usr/lib/modules ."
|
||||
PATH=/bin:/sbin:/usr/bin
|
||||
DRIVER=serial
|
||||
DRIVER_NAME=serial
|
||||
MODULE_REGEXP="serial\b"
|
||||
|
||||
ALLDEVS="/dev/ttyS?"
|
||||
if /bin/ls /dev/ttyS?? >& /dev/null ; then
|
||||
ALLDEVS="$ALLDEVS /dev/ttyS??"
|
||||
fi
|
||||
|
||||
SETSERIAL=""
|
||||
if test -x /bin/setserial ; then
|
||||
SETSERIAL=/bin/setserial
|
||||
elif test -x /sbin/setserial ; then
|
||||
SETSERIAL=/sbin/setserial
|
||||
fi
|
||||
|
||||
#
|
||||
# See if the serial driver is loaded
|
||||
#
|
||||
LOADED=""
|
||||
if test -f /proc/devices; then
|
||||
if grep -q " ttyS$" /proc/devices ; then
|
||||
LOADED="yes"
|
||||
else
|
||||
LOADED="no"
|
||||
fi
|
||||
fi
|
||||
|
||||
#
|
||||
# Find the serial driver
|
||||
#
|
||||
for i in $DIRS
|
||||
do
|
||||
if test -z "$MODULE" -a -f $i/$DRIVER.o ; then
|
||||
MODULE=$i/$DRIVER.o
|
||||
fi
|
||||
done
|
||||
|
||||
if ! test -f /proc/modules ; then
|
||||
MODULE=""
|
||||
fi
|
||||
|
||||
#
|
||||
# Handle System V init conventions...
|
||||
#
|
||||
case $1 in
|
||||
start)
|
||||
action="start";
|
||||
;;
|
||||
stop)
|
||||
action="stop";
|
||||
;;
|
||||
*)
|
||||
action="start";
|
||||
esac
|
||||
|
||||
if test $action = stop ; then
|
||||
if test -n ${SETSERIAL} -a "$LOADED" != "no" -a \
|
||||
`head -1 /etc/serial.conf`X = "###AUTOSAVE###X" ; then
|
||||
echo -n "Saving state of serial devices... "
|
||||
grep "^#" /etc/serial.conf > /etc/.serial.conf.new
|
||||
${SETSERIAL} -G -g ${ALLDEVS} >> /etc/.serial.conf.new
|
||||
mv /etc/serial.conf /etc/.serial.conf.old
|
||||
mv /etc/.serial.conf.new /etc/serial.conf
|
||||
echo "done."
|
||||
fi
|
||||
if test -n "$MODULE" ; then
|
||||
module=`grep $MODULE_REGEXP /proc/modules | awk '{print $1}'`
|
||||
if test -z "$module" ; then
|
||||
echo "The $DRIVER_NAME driver is not loaded."
|
||||
rm -f ${RCLOCKFILE}
|
||||
exit 0
|
||||
fi
|
||||
if rmmod $module ; then :; else
|
||||
echo "The $DRIVER_NAME driver could NOT be unloaded."
|
||||
exit 1;
|
||||
fi
|
||||
echo "The $DRIVER_NAME driver has been unloaded."
|
||||
fi
|
||||
rm -f ${RCLOCKFILE}
|
||||
exit 0
|
||||
fi
|
||||
|
||||
#
|
||||
# If not stop, it must be a start....
|
||||
#
|
||||
|
||||
if test -n "$MODULE" -a "$LOADED" != "yes" ; then
|
||||
if insmod -f $MODULE $DRIVER_ARG ; then
|
||||
true
|
||||
else
|
||||
echo "Couldn't load $DRIVER_NAME driver."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if test -f /etc/serial.conf ; then
|
||||
if test -n ${SETSERIAL} ; then
|
||||
grep -v ^# < /etc/serial.conf | while read device args
|
||||
do
|
||||
if [ ! "$device" = "" -a ! "$args" = "" ]; then
|
||||
${SETSERIAL} -z $device $args
|
||||
fi
|
||||
done
|
||||
fi
|
||||
else
|
||||
echo "###AUTOSAVE###" > /etc/serial.conf
|
||||
fi
|
||||
|
||||
touch ${RCLOCKFILE}
|
||||
${SETSERIAL} -bg ${ALLDEVS}
|
||||
50
etc/rc.d/rc.smartd
Normal file
50
etc/rc.d/rc.smartd
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# /etc/rc.d/rc.smartd
|
||||
#
|
||||
# Start/stop/restart the smartd daemon, which monitors the status of
|
||||
# S.M.A.R.T. compatible hard drives and reports any problems.
|
||||
#
|
||||
# By default, smartd will scan for all ATA/SATA and SCSI/SAS hard drives
|
||||
# and solid-state drives. Settings may be customized in /etc/smartd.conf.
|
||||
|
||||
# Import script defaults:
|
||||
if [ -r /etc/default/smartd ]; then
|
||||
. /etc/default/smartd
|
||||
fi
|
||||
|
||||
smart_start() {
|
||||
if [ -x /usr/sbin/smartd -a -r /etc/smartd.conf ]; then
|
||||
echo "Starting smartd: /usr/sbin/smartd -p /run/smartd.pid $SMARTD_OPTIONS &"
|
||||
/usr/sbin/smartd -p /run/smartd.pid $SMARTD_OPTIONS &
|
||||
fi
|
||||
}
|
||||
|
||||
smart_stop() {
|
||||
echo "Stopping smartd."
|
||||
if [ -r /run/smartd.pid ]; then
|
||||
kill $(cat /run/smartd.pid)
|
||||
else
|
||||
killall smartd
|
||||
fi
|
||||
}
|
||||
|
||||
smart_restart() {
|
||||
smart_stop
|
||||
sleep 1
|
||||
smart_start
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
'start')
|
||||
smart_start
|
||||
;;
|
||||
'stop')
|
||||
smart_stop
|
||||
;;
|
||||
'restart')
|
||||
smart_restart
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
esac
|
||||
@@ -28,11 +28,11 @@ sshd_start() {
|
||||
# make sure ssh dir exists on flash
|
||||
mkdir -p $SSH_BOOT
|
||||
# restore saved keys, config file, etc. (but not subdirs)
|
||||
cp $SSH_BOOT/* $SSH_ETC &>/dev/null
|
||||
chmod 600 $SSH_ETC/* &>/dev/null
|
||||
cp $SSH_BOOT/* $SSH_ETC 2>/dev/null
|
||||
chmod 600 $SSH_ETC/* 2>/dev/null
|
||||
# create host keys if needed and copy any newly generated key(s) back to flash
|
||||
ssh-keygen -A
|
||||
cp -n $SSH_ETC/ssh_host*_key* $SSH_BOOT/
|
||||
cp -n $SSH_ETC/ssh_host*_key* $SSH_BOOT/ 2>/dev/null
|
||||
# build configuration
|
||||
build_ssh
|
||||
# start daemon
|
||||
|
||||
56
etc/rc.d/rc.sysvinit
Executable file
56
etc/rc.d/rc.sysvinit
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# rc.sysvinit This file provides basic compatibility with SystemV style
|
||||
# startup scripts. The SystemV style init system places
|
||||
# start/stop scripts for each runlevel into directories such as
|
||||
# /etc/rc.d/rc3.d/ (for runlevel 3) instead of starting them
|
||||
# from /etc/rc.d/rc.M. This makes for a lot more init scripts,
|
||||
# and a more complicated execution path to follow through if
|
||||
# something goes wrong. For this reason, Slackware has always
|
||||
# used the traditional BSD style init script layout.
|
||||
#
|
||||
# However, many binary packages exist that install SystemV
|
||||
# init scripts. With rc.sysvinit in place, most well-written
|
||||
# startup scripts will work. This is primarily intended to
|
||||
# support commercial software, though, and probably shouldn't
|
||||
# be considered bug free.
|
||||
#
|
||||
# Written by Patrick Volkerding <volkerdi@slackware.com>, 1999
|
||||
# from an example by Miquel van Smoorenburg <miquels@cistron.nl>.
|
||||
|
||||
# Run an init script:
|
||||
startup() {
|
||||
case "$1" in
|
||||
*.sh)
|
||||
sh "$@"
|
||||
;;
|
||||
*)
|
||||
"$@"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Set onlcr to avoid staircase effect.
|
||||
stty onlcr 0>&1
|
||||
|
||||
if [ "$runlevel" = "" ]; then
|
||||
runlevel=$RUNLEVEL
|
||||
export runlevel
|
||||
prevlevel=$PREVLEVEL
|
||||
export prevlevel
|
||||
fi
|
||||
|
||||
# Run kill scripts:
|
||||
for script in /etc/rc.d/rc$runlevel.d/K* ; do
|
||||
if [ -x $script ]; then
|
||||
startup $script stop
|
||||
fi
|
||||
done
|
||||
|
||||
# Now do the startup scripts:
|
||||
for script in /etc/rc.d/rc$runlevel.d/S* ; do
|
||||
if [ -x $script ]; then
|
||||
startup $script start
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
#!/bin/bash
|
||||
# Start/stop wireguard interfaces
|
||||
|
||||
log=/var/log/wg-quick.log
|
||||
SYSTEM=/sys/class/net
|
||||
WIREGUARD=/etc/wireguard
|
||||
LOG=/var/log/wg-quick.log
|
||||
TMP=/tmp/wg-quick.tmp
|
||||
|
||||
start() {
|
||||
if ! iptables -S | grep -qom1 "WIREGUARD$"; then
|
||||
@@ -12,59 +15,67 @@ start() {
|
||||
ip6tables -N WIREGUARD
|
||||
ip6tables -A FORWARD -j WIREGUARD
|
||||
fi
|
||||
if [[ ! -d /etc/wireguard ]]; then
|
||||
if [[ ! -d $WIREGUARD ]]; then
|
||||
mkdir -p /boot/config/wireguard
|
||||
ln -s /boot/config/wireguard /etc
|
||||
fi
|
||||
tmp=/tmp/wg-quick.tmp
|
||||
autostart=$(cat /etc/wireguard/autostart 2>/dev/null)
|
||||
# get active interface
|
||||
[[ -e $SYSTEM/bond0 ]] && NIC=bond0 || NIC=eth0
|
||||
[[ -e $SYSTEM/br0 ]] && NIC=br0
|
||||
AUTOSTART=$(cat $WIREGUARD/autostart 2>/dev/null)
|
||||
# Loop thru all configured WG tunnels
|
||||
for WG in $(ls --indicator-style=none /etc/wireguard/*.conf 2>/dev/null); do
|
||||
for WG in $(ls --indicator-style=none $WIREGUARD/*.conf 2>/dev/null); do
|
||||
# remove path and extension
|
||||
WG=${WG##*/}; WG=${WG%.*}
|
||||
WG=$(basename -s .conf $WG)
|
||||
# create routing table for network used by docker containers
|
||||
index=$((${WG:2}+200))
|
||||
network="172.31.$index.0/24"
|
||||
if [[ -z $(ip rule|grep -Pom1 "from $network") ]]; then
|
||||
ip -4 rule add from $network table $index
|
||||
ip -4 route add unreachable default table $index
|
||||
TABLE=$((${WG:2}+200))
|
||||
NETWORK="172.31.$TABLE.0/24"
|
||||
if [[ -z $(ip rule|grep -Pom1 "from $NETWORK") ]]; then
|
||||
ip -4 rule add from $NETWORK table $TABLE
|
||||
ip -4 route add unreachable default table $TABLE
|
||||
fi
|
||||
# interface has changed?
|
||||
if ! grep -qm1 "dev $NIC " $WIREGUARD/$WG.conf; then
|
||||
# update wireguard configuration
|
||||
logger -t $(basename $0) "updated wireguard $WG configuration"
|
||||
sed -ri "s/dev (br0|bond0|eth0) /dev $NIC /" $WIREGUARD/$WG.conf
|
||||
fi
|
||||
# autostart WG tunnel?
|
||||
if [[ $autostart == *"$WG"* ]]; then
|
||||
if [[ $AUTOSTART =~ $WG ]]; then
|
||||
# Get gateway IP address
|
||||
gw=$(grep -Pom1 '^PostUp=ip -4 route add [\d\.]+/\d+ via \K[\d\.]+' /etc/wireguard/$WG.conf)
|
||||
if [[ -n $gw ]]; then
|
||||
timer=10
|
||||
GW=$(grep -Pom1 '^PostUp=ip -4 route add [\d\.]+/\d+ via \K[\d\.]+' $WIREGUARD/$WG.conf)
|
||||
if [[ -n $GW ]]; then
|
||||
TIMER=10
|
||||
# wait for gateway to become reachable (max 10 seconds)
|
||||
while [[ -z $(ip -4 route show default|grep -Pom1 "$gw ") && $timer -gt 0 ]]; do
|
||||
((timer--))
|
||||
while [[ -z $(ip -4 route show default|grep -Pom1 "$GW ") && $TIMER -gt 0 ]]; do
|
||||
sleep 1
|
||||
((TIMER--))
|
||||
done
|
||||
fi
|
||||
# start WG tunnel
|
||||
wg-quick up "$WG" 2>$tmp
|
||||
echo "wg-quick up $WG (autostart)" >>$log
|
||||
cat $tmp >>$log
|
||||
echo >>$log
|
||||
wg-quick up $WG 2>$TMP
|
||||
echo "wg-quick up $WG (autostart)" >>$LOG
|
||||
cat $TMP >>$LOG
|
||||
echo >>$LOG
|
||||
# WG tunnel for docker container?
|
||||
if grep -qm1 '^TYPE:1="8"' /etc/wireguard/$WG.cfg; then
|
||||
if grep -qm1 '^TYPE:1="8"' $WIREGUARD/$WG.cfg; then
|
||||
# update routing table for WG tunnels used by containers
|
||||
table=$(grep -Pom1 'fwmark \K[\d]+' $tmp)
|
||||
route=$(grep -Pom1 '^Address=\K.+$' /etc/wireguard/$WG.conf)
|
||||
TABLE=$(grep -Pom1 'fwmark \K[\d]+' $TMP)
|
||||
ROUTE=$(grep -Pom1 '^Address=\K.+$' $WIREGUARD/$WG.conf)
|
||||
sleep 1
|
||||
ip -4 route flush table $table
|
||||
ip -4 route add $route dev $WG table $table
|
||||
ip -4 route flush table $TABLE
|
||||
ip -4 route add $ROUTE dev $WG table $TABLE
|
||||
fi
|
||||
fi
|
||||
done
|
||||
rm -f $tmp
|
||||
rm -f $TMP
|
||||
}
|
||||
|
||||
stop() {
|
||||
for WG in $(wg show interfaces); do
|
||||
echo "wg-quick down $WG (autostop)" >>$log
|
||||
wg-quick down "$WG" 2>>$log
|
||||
echo >>$log
|
||||
echo "wg-quick down $WG (autostop)" >>$LOG
|
||||
wg-quick down $WG 2>>$LOG
|
||||
echo >>$LOG
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
58
etc/rc.d/rc.wsdd2
Executable file
58
etc/rc.d/rc.wsdd2
Executable file
@@ -0,0 +1,58 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# /etc/rc.d/rc.wsdd2
|
||||
#
|
||||
# start/stop/restart the wsdd2 daemon.
|
||||
#
|
||||
# To make wsdd2 start automatically at boot make sure this
|
||||
# file is executable, and add the following entry to rc.local
|
||||
# after the samba test (uncommented)
|
||||
|
||||
# if [ -x /etc/rc.d/rc.wsdd2 ]; then
|
||||
# /etc/rc.d/rc.wsdd2 start
|
||||
# fi
|
||||
|
||||
# you may also add the following entry to rc.local_shutdown
|
||||
# (uncommented)
|
||||
|
||||
# if [ -x /etc/rc.d/rc.wsdd2 ]; then
|
||||
# /etc/rc.d/rc.wsdd2 stop
|
||||
# fi
|
||||
|
||||
wsdd2_start() {
|
||||
if [ -r /etc/samba/smb.conf -a -x /etc/rc.d/rc.samba -a -x /usr/sbin/wsdd2 ]; then
|
||||
echo "Starting wsdd2: /usr/bin/wsdd2 -d"
|
||||
/usr/sbin/wsdd2 -d
|
||||
elif [ ! -r /etc/samba/smb.conf ]; then
|
||||
echo "ERROR: samba not configured, so wsdd2 has no service to advertise"
|
||||
fi
|
||||
}
|
||||
wsdd2_stop() {
|
||||
#check something is running before trying to kill it.
|
||||
if [ "x`ps -A|grep ' wsdd2'|wc -l`" != "x0" ]; then
|
||||
killall wsdd2
|
||||
fi
|
||||
}
|
||||
wsdd2_restart() {
|
||||
wsdd2_stop
|
||||
sleep 1
|
||||
wsdd2_start
|
||||
}
|
||||
case "$1" in
|
||||
'start')
|
||||
#we don't want to run this more than once,
|
||||
#so kill off any instance already running
|
||||
wsdd2_stop
|
||||
wsdd2_start
|
||||
;;
|
||||
'stop')
|
||||
wsdd2_stop
|
||||
;;
|
||||
'restart')
|
||||
wsdd2_restart
|
||||
;;
|
||||
*)
|
||||
# default is start
|
||||
wsdd2_start
|
||||
esac
|
||||
|
||||
@@ -141,7 +141,7 @@ for ((i=0;i<${SYSNICS:-1};i++)); do
|
||||
echo "USE_DHCP6:0=\"${USE_DHCP6[$i]}\"" >>$ini
|
||||
if [[ ${USE_DHCP6[$i]} == yes ]]; then
|
||||
# get auto assigned ipv6 address & prefix
|
||||
NET6=($(ip -br -6 addr show $IFACE scope global|awk '{sub("/"," ",$3);print $3;exit}'))
|
||||
NET6=($(ip -br -6 addr show $IFACE scope global|awk '{sub("/"," ",$NF);print $NF;exit}'))
|
||||
GW6=$(ip -6 route show default dev $IFACE|awk '{print $3;exit}')
|
||||
echo "IPADDR6:0=\"${NET6[0]}\"" >>$ini
|
||||
echo "NETMASK6:0=\"${NET6[1]}\"" >>$ini
|
||||
@@ -194,7 +194,7 @@ for ((i=0;i<${SYSNICS:-1};i++)); do
|
||||
if [[ ${USE_DHCP6[$i,$j]} == yes ]]; then
|
||||
DEV=$IFACE.${VLANID[$i,$j]}
|
||||
# get auto assigned ipv6 address & prefix
|
||||
NET6=($(ip -br -6 addr show $DEV scope global|awk '{sub("/"," ",$3);print $3;exit}'))
|
||||
NET6=($(ip -br -6 addr show $DEV scope global|awk '{sub("/"," ",$NF);print $NF;exit}'))
|
||||
GW6=$(ip -6 route show default dev $DEV|awk '{print $3;exit}')
|
||||
echo "IPADDR6:$j=\"${NET6[0]}\"" >>$ini
|
||||
echo "NETMASK6:$j=\"${NET6[1]}\"" >>$ini
|
||||
@@ -235,8 +235,8 @@ if [[ -z $interface || "eth0 br0 bond0" =~ $interface ]]; then
|
||||
# find management interface
|
||||
[[ -e /sys/class/net/bond0 ]] && dev=bond0 || dev=eth0
|
||||
[[ -e /sys/class/net/br0 ]] && dev=br0
|
||||
IPv4=$(ip -br -4 addr show $dev scope global|awk '{print $3}')
|
||||
IPv6=$(ip -br -6 addr show $dev scope global|awk '{print $3}')
|
||||
IPv4=$(ip -br -4 addr show $dev scope global|awk '{print $3;exit}')
|
||||
IPv6=$(ip -br -6 addr show $dev scope global|awk '{print $NF;exit}')
|
||||
[[ -n $IPv4 ]] && echo " IPv4 address: ${IPv4%/*}">>/etc/issue || echo " IPv4 address: not set">>/etc/issue
|
||||
[[ -n $IPv6 ]] && echo " IPv6 address: ${IPv6%/*}">>/etc/issue || echo " IPv6 address: not set">>/etc/issue
|
||||
echo >>/etc/issue
|
||||
|
||||
Reference in New Issue
Block a user