Skip to content

Commit fb8a939

Browse files
committed
Support /etc/sysctl.d/ for Debian-based systems
On Debian-based systems, /etc/sysctl.conf doesn't exist and /etc/sysctl.d/ directory is used instead. Modified xcatconfig to prefer /etc/sysctl.d/99-xcat.conf when the directory exists, falling back to /etc/sysctl.conf for backward compatibility.
1 parent 661b579 commit fb8a939

File tree

1 file changed

+44
-24
lines changed

1 file changed

+44
-24
lines changed

xCAT-server/sbin/xcatconfig

Lines changed: 44 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ exit;
623623
#-----------------------------------------------------------------------------
624624

625625
=head3 usage
626-
626+
627627
Displays message for -h option
628628
629629
=cut
@@ -652,7 +652,7 @@ sub verbose
652652
#-----------------------------------------------------------------------------
653653

654654
=head3 genSSHRootKeys
655-
655+
656656
Will generate a new ssh rsa key for the root user, if it does not exist or if requested by the input -k flag.
657657
658658
=cut
@@ -833,7 +833,7 @@ sub genSSHRootKeys
833833
#-----------------------------------------------------------------------------
834834

835835
=head3 settunables
836-
836+
837837
Will set the default suggested tunables on the Management Node or service node for Linux
838838
839839
=cut
@@ -867,30 +867,50 @@ sub settunables
867867
}
868868

869869
# set for after reboot
870-
if (!(-f "/etc/sysctl.conf.xcatbackup")) { # not already backed up
871-
$cmd = "cp /etc/sysctl.conf /etc/sysctl.conf.xcatbackup";
870+
my $sysctl_file;
871+
if (-d "/etc/sysctl.d") {
872+
$sysctl_file = "/etc/sysctl.d/99-xcat.conf";
873+
if (!(-f "$sysctl_file")) {
874+
$cmd = "touch $sysctl_file";
875+
my $outref = xCAT::Utils->runcmd("$cmd", 0);
876+
if ($::RUNCMD_RC != 0)
877+
{
878+
xCAT::MsgUtils->message('E', "Could not create $sysctl_file.");
879+
exit 1;
880+
}
881+
}
882+
} elsif (-f "/etc/sysctl.conf") {
883+
$sysctl_file = "/etc/sysctl.conf";
884+
} else {
885+
xCAT::MsgUtils->message('E', "Could not find /etc/sysctl.d directory or /etc/sysctl.conf.");
886+
exit 1;
887+
}
888+
889+
my $sysctl_backup = "$sysctl_file.xcatbackup";
890+
if (!(-f "$sysctl_backup")) {
891+
$cmd = "cp $sysctl_file $sysctl_backup";
872892
my $outref = xCAT::Utils->runcmd("$cmd", 0);
873893
if ($::RUNCMD_RC != 0)
874894
{
875-
xCAT::MsgUtils->message('E', "Could not backup /etc/sysctl.conf.");
895+
xCAT::MsgUtils->message('E', "Could not backup $sysctl_file.");
876896
exit 1;
877897
}
878898
}
879899

880900
#delete all occurance of the attribute and then add xCAT settings
881-
`sed -i '/net.ipv4.neigh.default.gc_thresh1 /'d /etc/sysctl.conf`;
882-
`echo "net.ipv4.neigh.default.gc_thresh1 = 1024" >>/etc/sysctl.conf`;
883-
`sed -i '/net.ipv4.neigh.default.gc_thresh2 /'d /etc/sysctl.conf`;
884-
`echo "net.ipv4.neigh.default.gc_thresh2 = 4096" >>/etc/sysctl.conf`;
885-
`sed -i '/net.ipv4.neigh.default.gc_thresh3 /'d /etc/sysctl.conf`;
886-
`echo "net.ipv4.neigh.default.gc_thresh3 = 8192" >>/etc/sysctl.conf`;
901+
`sed -i '/net.ipv4.neigh.default.gc_thresh1 /'d $sysctl_file`;
902+
`echo "net.ipv4.neigh.default.gc_thresh1 = 1024" >>$sysctl_file`;
903+
`sed -i '/net.ipv4.neigh.default.gc_thresh2 /'d $sysctl_file`;
904+
`echo "net.ipv4.neigh.default.gc_thresh2 = 4096" >>$sysctl_file`;
905+
`sed -i '/net.ipv4.neigh.default.gc_thresh3 /'d $sysctl_file`;
906+
`echo "net.ipv4.neigh.default.gc_thresh3 = 8192" >>$sysctl_file`;
887907

888908
}
889909

890910
#-----------------------------------------------------------------------------
891911

892912
=head3 genSSHNodeHostKey
893-
913+
894914
If node private node hostkeys do not exist in either directory or force option
895915
or generate host key option, we need to generate them
896916
These keys are installed on the nodes in /etc/ssh directory and allow the
@@ -1069,7 +1089,7 @@ sub is_redhat6sp4
10691089
#-----------------------------------------------------------------------------
10701090

10711091
=head3 initDB
1072-
1092+
10731093
Will initialize the DB if it does not already exist, also updates with
10741094
new data needed or database changes during xCAT install.
10751095
@@ -1526,7 +1546,7 @@ sub initDB
15261546
#-----------------------------------------------------------------------------
15271547

15281548
=head3 check for otherpkgs
1529-
1549+
15301550
Check to see if other pkgs exists in postscripts table.
15311551
If it does not we will be putting it in postbootscripts
15321552
return exist_flag
@@ -1577,7 +1597,7 @@ sub checkotherpkgs
15771597
#-----------------------------------------------------------------------------
15781598

15791599
=head3 genCredentials
1580-
1600+
15811601
Will generate the xCAT credential, if new install or requested to
15821602
regenerate.
15831603
@@ -1800,7 +1820,7 @@ sub setupAIXIPMITool
18001820
#-----------------------------------------------------------------------------
18011821

18021822
=head3 setupAIXexports
1803-
1823+
18041824
Set AIX exports
18051825
18061826
=cut
@@ -1836,7 +1856,7 @@ sub setupAIXexports
18361856
#-----------------------------------------------------------------------------
18371857

18381858
=head3 setupLinuxexports
1839-
1859+
18401860
Set Linux exports
18411861
18421862
=cut
@@ -1959,7 +1979,7 @@ sub setupLinuxexports
19591979
#-----------------------------------------------------------------------------
19601980

19611981
=head3 mknb
1962-
1982+
19631983
Creates a network boot root image on Linux
19641984
Run mknb to put xCAT-genesis-scripts-x86_64 and xCAT-genesis-base-x86_64 together and in /tftpboot
19651985
From 2.12.2, both xCAT-genesis-scripts-x86_64 and xCAT-genesis-scripts-ppc64 will be installed.
@@ -2003,7 +2023,7 @@ sub mknb
20032023
#-----------------------------------------------------------------------------
20042024

20052025
=head3 makenetworks
2006-
2026+
20072027
Runs makenetworks on AIX and Linux
20082028
20092029
=cut
@@ -2030,7 +2050,7 @@ sub makenetworks
20302050
#-----------------------------------------------------------------------------
20312051

20322052
=head3 setuphttp
2033-
2053+
20342054
initializes http on Linux
20352055
20362056
=cut
@@ -2102,7 +2122,7 @@ sub setuphttp
21022122
#-----------------------------------------------------------------------------
21032123

21042124
=head3 cleanupPSTable
2105-
2125+
21062126
Any line in the postscripts table that has the following
21072127
entry will have xcatserver,xcatclient remove because they
21082128
are not called by servicenode
@@ -2214,7 +2234,7 @@ sub cleanupPSTable
22142234
#-----------------------------------------------------------------------------
22152235

22162236
=head3 setupMNinDB
2217-
2237+
22182238
Will add the management node to the noderes table with group=__mgmtnode
22192239
Will add the management node to the servicenode tble with group=__mgmtnode
22202240
@@ -2315,7 +2335,7 @@ sub setupMNinDB
23152335
#-----------------------------------------------------------------------------
23162336

23172337
=head3 startnamedonboot
2318-
2338+
23192339
Configure named to start on boot
23202340
23212341
=cut

0 commit comments

Comments
 (0)