Giter VIP home page Giter VIP logo

initscripts's Introduction

initscripts

Build Status Differential ShellCheck Differential ShellCheck CodeQL Mergify Status

This repository contains source code for legacy System V initscripts, which are primarily used in Linux distributions like e.g.:

Since most of the major Linux distributions have already switched to systemd, the initscripts concept is quite outdated nowadays. As a result, this repository provides primarily only the support for other initscripts that might still exist out there.

The above mentioned support includes e.g. the /etc/rc.d/init.d/functions or /usr/sbin/service files.

Another functionality this source code provides includes:

  • network-scripts - legacy scripts for manipulating of network devices
  • readonly-root - service for configuring the read-only root support
  • netconsole - service for initializing of network console logging

For the RPM based distributions we also provide a specfile for easier packaging.

Future of initscripts

As mentioned above, the initscripts concept is outdated nowadays, and de-facto obsolete. Most of the work on this repository is just a maintenance, and we do not plan on extending the support for initscripts in the future in any way.

We intend to convert the rest of the remaining services into systemd units, and remove them eventually if possible.

And we have also started our work on decomissioning of network-scripts as well. This means no new functionality will be added into them. In case you need some you should ask for it to be implemented in NetworkManager, if it isn't already.

No longer active branches

Follow the steps in our wiki - how to access inactive branches - in case you need to check out old git branches for any reason.

Bugs reporting

If you find a bug, we would like to hear about it -- although we can't guarantee we will be able to fix it... The best way to report bugs differs for each distribution:

  • RHEL | CentOS - create a bug report in bugzilla for corresponding RHEL version
  • Fedora | Other - create a new issue directly here on GitHub

NOTE: Bug reports created for Fedora in bugzilla usually take a lot of time to resolve. We advise to use GitHub instead.

initscripts's People

Contributors

0xf2 avatar anipeter avatar bachradsusi avatar dcantrell avatar deekej avatar glezos avatar haraldh avatar hisaito avatar igorpsoares avatar jamacku avatar jaymzh avatar keszybz avatar kmilos avatar lanurmi avatar lnykryn avatar milankerslager avatar mswilson avatar mtrmac avatar nalind avatar ngothan avatar norwayfun avatar paul-j-brown avatar piotrdrag avatar poettering avatar rhatdan avatar richard-allen avatar scop avatar vathpela avatar wenottingham avatar yovko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

initscripts's Issues

[RHBZ] ifdown on alias removes all IPv6 addresses of parent interface

Shutting down an (ipv4) interface alias (e.g. eth0:1) flushes/removes all ipv6 addresses on the parent interface (e.g. eth0). [RHBZ #870271 | RHBZ #842421]

Steps to Reproduce:

  1. configure some interface aliases - parent eth0 has ipv6 connectivity (ipv6 autoconfig):
$ ifconfig | egrep 'Link|inet'
eth0       Link encap:Ethernet  HWaddr 52:54:00:37:1D:02
          inet addr:192.0.2.1  Bcast:192.0.2.255  Mask:255.255.255.0
          inet6 addr: 2001:db8::5054:ff:fe37:1d02/64 Scope:Global
          inet6 addr: fe80::5054:ff:fe37:1d02/64 Scope:Link
eth0:2    Link encap:Ethernet  HWaddr 52:54:00:37:1D:02
          inet addr:192.0.2.2  Bcast:192.0.2.255  Mask:255.255.255.0
eth0:3    Link encap:Ethernet  HWaddr 52:54:00:37:1D:02  
          inet addr:192.0.2.3  Bcast:192.0.2.255  Mask:255.255.255.0

The interface alias is shutdown, however all ipv6 addresses of the parent interface are also removed:

$ ifconfig | egrep 'Link|inet'
eth0      Link encap:Ethernet  HWaddr 52:54:00:37:1D:02  
          inet addr:192.0.2.1  Bcast:192.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::5054:ff:fe37:1d02/64 Scope:Link
eth0:2    Link encap:Ethernet  HWaddr 52:54:00:37:1D:02  
          inet addr:192.0.2.2  Bcast:192.0.2.255  Mask:255.255.255.0

/sbin/ifdown calls ifdown-eth which correctly shuts down the alias address and then calls ifdown-ipv6 on the alias device.

ifdown-ipv6 munges the alias device name from "eth0:X" to the realdevice name of "eth0" and then issues an "ipv6_cleanup_device eth0" which erroneously removes all addresses on the parent device.

We have fixed this by modifying ifdown-ipv6 to only attempt to shutdown the alias, which will be a silent noop because the 'eth0:X' alias interface has no ipv6 addresses:

% diff -ur ifdown-ipv6.*
--- ifdown-ipv6.a   2012-10-26 12:22:52.000000000 +1030
+++ ifdown-ipv6.b   2012-10-26 12:22:59.000000000 +1030
@@ -46,6 +46,7 @@
 source_config

 REALDEVICE=${DEVICE%%:*}
+DEVICE=$REALDEVICE

 [ -f /etc/sysconfig/network-scripts/network-functions-ipv6 ] || exit 1
 . /etc/sysconfig/network-scripts/network-functions-ipv6
@@ -131,4 +132,4 @@
 fi

 # Delete all current configured IPv6 addresses on this interface
-ipv6_cleanup_device $REALDEVICE
+ipv6_cleanup_device $DEVICE

NOTE: Similar behaviour for IPv4 has been fixed by this commit.

logic of is_hostname_set is incorrect

Hi ,

The logic of is_hostname_set in not right, it introduced in [1]:
is_hostname_set ()
{
case "${HOSTNAME}" in
'(none)' | 'localhost' | 'localhost.localdomain')
# Hostname NOT set:
return 1
;;
*)
# Hostname IS set:
return 0
;;
esac
}

when Hostname NOT set, it should return 0, When Hostname IS set, it should return 1.
Otherwise, need_hostname will return a wrong value in the case:
NO_DHCP_HOSTNAME is not set, and hostname is already set.
If dhcpclient request hostname option, it will overwrite existed hostname.
Thanks.

[1] 2ea1dcf#diff-4003056111e3c781065006ea15b573ea

Create the CHANGELOG files

We should start using some sort of CHANGELOG file so it's easier to track changes to behaviour. I guess it would be wise to use 2 changelog files - one for network scripts, and one for the rest.

[ANNOUNCEMENT] - Split initscripts and network-scripts to different packages

We are planning to divide initscripts package into two packages for RHEL9+. Where network-scripts will be in there own package in EPEL (unsupported) and initscripts as such will remain supported.

Reason being to encourage people to use NetworkManager instead of legacy network-scripts.

We are now in planning phase and we are looking for your opinions, so don't hesitate to reach to us.

Introduce PEERROUTES directive

Right now we are able to force network scripts not to obtain DNS servers from DHCP server (if configured in a specific way). However, we are not able to force network scripts not to obtain routes fro DHCP server.

We should start recognize a new directive PEERROUTES in the future, as NetworkManager does.

Move 'initscripts.tmpfile.d' into different package (or remove it)

We should consider moving this into different package, like setup. Alternatively, since we're maintaining the *.spec file and the 'initscripts.tmpfile.d' now contains only one instructions to create /var/run/netreport/ folder, we could just add it into specfile installation phase. @lnykryn, what do you think?

Setting RES_OPTIONS in /etc/sysconfig/network is not documented anywhere

There are four man pages for dhclient, a man page for nm-settings-ifcfg-rh and also /usr/share/doc/initscripts/sysconfig.txt but nothing mentions that if you put RES_OPTIONS = rotate into /etc/sysconfig/network that /usr/sbin/dhclient-script will add options rotate to /etc/resolv.conf. There is an indication in the resolv.conf(5) man page that RES_OPTIONS comes from the environment but it does not mention how to set RES_OPTIONS into the environment. There is an indication in the nm-settings-ifcfg-rh(5) man page that RES_OPTIONS is an Ifcfg-rh variable but nothing about the fact that you set RES_OPTIONS in /etc/sysconfig/network.

You can see that it does by examining /usr/sbin/dhclient-script

if [ -f /etc/sysconfig/network ]; then
    . /etc/sysconfig/network
fi
... skip backward to the function definition: make_resolv_conf() ...

        if [ -n "${RES_OPTIONS}" ]; then
            echo "options ${RES_OPTIONS}" >> "${rscf}"
        fi

There is a section in /usr/share/doc/initscripts/sysconfig.txt named /etc/sysconfig/network so that would make a good place for documentation about the RES_OPTIONS.

network device renaming doesn't work with mt76x0u driver

Fedora 31, initscripts-10.02-2.fc31.x86_64

[    4.023015] usb 3-6.4: new high-speed USB device number 6 using xhci_hcd
[    4.108638] usb 3-6.4: New USB device found, idVendor=0e8d, idProduct=7610, bcdDevice= 1.00
[    4.110294] usb 3-6.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    4.111924] usb 3-6.4: Product: WiFi
[    4.113519] usb 3-6.4: Manufacturer: MediaTek
[    4.115084] usb 3-6.4: SerialNumber: 1.0
[   13.736091] usb 3-6.4: reset high-speed USB device number 6 using xhci_hcd
[   13.818419] usb 3-6.4: ASIC revision: 76100002 MAC revision: 76502000
[   14.529163] usb 3-6.4: EEPROM ver:02 fae:04
...
[   15.782371] usbcore: registered new interface driver mt76x0u

Assigned device name is wlan0

$ iw dev
phy#1
        Interface wlan0
                ifindex 4
                wdev 0x100000001
                addr e2:ee:04:f2:XX:YY
                type managed
                txpower 0.00 dBm
                multicast TXQ:

I guess it can be related how those drivers works:
Intel dongle has the correct name (wlp6s0).

$ ls -lh /sys/class/net/wlp6s0/device/driver
lrwxrwxrwx 1 root root 0 Jan 14 12:28 /sys/class/net/wlp6s0/device/driver -> ../../../../../../bus/pci/drivers/iwlwifi/

mt76XXX:

$ ls -lh /sys/class/net/wlan0/device/driver
lrwxrwxrwx 1 root root 0 Jan 14 12:28 /sys/class/net/wlan0/device/driver -> ../../../../../../../../../bus/usb/drivers/usb/

Add 'LICENSE' file

We should add Copyright which states that the files in this git repository that are under Red Hat's Copyright are actually distributed under GPLv2 [COPYING]. We need a clarification, what actually applies for the initscripts files.

Right now, we don't have such a thing.

network-scripts: ifup-local is never run for bridge member interfaces

ifup-eth currently calls exit 0 when setting up a bridge member interface, which leads to ifup-local never being run. We're currently working around this in our environment with this /sbin/ifup-pre-local script.

#!/bin/bash

. /etc/init.d/functions

cd /etc/sysconfig/network-scripts
. ./network-functions

[ -f ../network ] && . ../network

CONFIG=${1}

need_config "${CONFIG}"

source_config

# If we're not setting up a bridge member interface, exit now
[ -z "${BRIDGE}" -a -z "${OVS_BRIDGE}" ] && exit 0

# This will run ifup-eth, then ifup-local, but then /sbin/ifup (our caller)
# will RE-RUN ifup-eth. This seems to be ok in practice, as most of the things
# ifup-eth does are idempotent. Note that we have to do this because ifup-eth
# will 'exit 0' in the middle when setting up a bridge member interface, thus
# preventing ifup-local from even being called.
OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}"

if [ ! -x ${OTHERSCRIPT} ]; then
  OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-eth"
fi

${OTHERSCRIPT} ${CONFIG} $2

if [ -x /sbin/ifup-local ]; then
  /sbin/ifup-local ${DEVICE}
fi

# give it some time to settle
sleep 2

exit 0

Note: this is a long standing bug, dating back to at least 2014, but I'd forgotten to file it until now.

Add deprecation warning for aliases

This concept was a workaround from previous times, when there was no easy way for one interface to have multiple IP adresses in kernel. Nowadays this is no longer true, and people should stop using the aliases as a result...

Adding the deprecation message into ifup-aliases could potentionally help us learn how people are using the aliases. If there are some valid usecases for the aliases use, we can then ask NetworkManager guys to implement that functionality if needed.

genhostid always creates a new hostid

When running genhostid it always stores a new value into /etc/hostid, even though genhostid(1) says this will happen if /etc/hostid does not already exist.

It looks like the bug is that it checks st.st_size >= sizeof (n) but on a 64-bit system this will always be false because this is declared as long int n and will be 8 bytes, but /etc/hostid is always a 32-bit value. It should be enough to declare this as int n and then everything should work properly.

Drop 'usleep' from initscripts completely in F28.

There's no longer need to have this utility as part of the initscripts package. The more suitable package would be the coreutils package.

NOTE: This utility can't be just replaced by 'sleep' utility, because it has different behaviour and cmdline options.

Keep both IPv4 and IPv6 DNS server (provided by dhcp server) addresses in /etc/resolv.conf

In one scenario, users adopt both IPv4 and IPv6, and devices get addresses from IPv4 and IPv6 dhcp servers, respectively.
In addition, each dhcp servcer provides its own DNS option. For example, the DNS server provied by IPv4 dhcp server is 2.2.2.2, while the DNS server obtained from IPv6 dhcp server is FCD0::2. However, the /etc/resolv.conf file only keeps one DNS server address from IPv4 or IPv6 dhcp server, which will result in the failure to resolve another protocol domain name.

In /etc/sysconfig/network-scripts/network-functions file, the /etc/resolv.conf will be rewritten by change_resolv_conf func rather than appending new dns server to the file as follows,

533 # Invoke this when /etc/resolv.conf has changed:
534 change_resolv_conf ()
535 {
		...
538     oldumask=$(umask)
539     umask 022
		...
566        fi;
567     fi;
568     (echo "$s" > /etc/resolv.conf;) >/dev/null 2>&1;
569     r=$?
		...
576     umask $oldumask
577     return $r;
578 }

Is there a good way to keep both DNS server addresses from IPv4 and IPv6 dhcp servers at the same time? Finally, users can obtain the available /etc/resolv.conf as follows,
#cat /etc/resolv.conf
nameserver 2.2.2.2
nameserver fcd0::2

Use is_true() & is_false() everywhere

Currently, there are still some places where there are hardcoded tests for yes and no values, instead of using is_true and is_false functions.

Example:

toggle_value ()
{
    if [ "$2" = "yes"    -o "$2" = "YES" ] ; then
        echo "$1 on"
    elif [ "$2" = "no"    -o "$2" = "NO" ] ; then
        echo "$1 off"
    else
        echo ''
    fi
}

For more sane approach, we should no longer use this parsing.

Add README.md file

We should add some README file, with regularly updated links and more info on the release process & how to contribute. It could possibly have the warning section about what not to do when using initscripts as well.

Move sysconfig/readonly-root to different package

In the future, the initscripts package should provide only necessary utilities to handle initscripts. The actual configuration for the system should live in a different package, to have a nice separation between functionality & distribution configuration.

The readonly config-file could live in the setup package.

Also, we should make sure the initscripts function correctly without the readonly file being present on the system.

ifdown-post removes user's ppp configuration

/etc/sysconfig/network-scripts/ifdown-post started to delete user's files in /etc/ppp/peers/ after 5d61564

ifdown-post executes from /etc/ppp/ip-down every time ppp used, so it deletes files in /etc/ppp/peers every time when ppp shuts down even if it wasnt's spawnd from network-scripts.

please migrate to the new Fedora translation platform

Hello, the Fedora project migrates its translation platform to Weblate [1].

This tool directly interact with your git repository, and requires us to know:

  • [mandatory] which branch is your development branch?
  • [mandatory] have you merged latest translation from Zanata and locked the project?
  • [info] Weblate will handle updates when pot file changes, don't edit po files for this [2]
  • [optional] what is the license of translation? (please use a code from https://spdx.org/licenses/)
  • [optional] do you have any announcement/warning you would like to display to the translators? (it will be displayed in Weblate)
  • [optional] do you need us to activate any specific checks? (this is a setting per component [3])
  • [optional] do you need us to automatically detect new translation files? (typical usecase: website translation with one translation file per page)

Please note:

  • For github hosted projects, Weblate open pull request. For other project, you'll have to add a key to allow commits.
  • In Weblate's vocable, one project is a group of component. Each component is a translation file. You can have many projects or many components or both.
  • You can change your mind over time, just reach [email protected]

[1] https://communityblog.fedoraproject.org/fedora-localization-platform-migrates-to-weblate/
[2] https://docs.weblate.org/en/latest/admin/continuous.html#avoiding-merge-conflicts
[3] https://docs.weblate.org/en/latest/user/checks.html#translation-checks

How to install dnf on Fedora 28

By mistake, I removed libsolv and all its dependencies including dnf

Tried running this command

yum-deprecated install dnf

however getting Error: invalid version flag: if

pls help me fix this

Move sysctl.conf* files into kernel configuration files of Fedora

It does not make sense to keep kernel configuration files in initscripts, when we have specific Fedora kernel configurations in different package AFAIK. We should try to move the files, but it might not be easy to convince people to do accept these changes.

In network disable and NetworkManager enable, the network failed to start the NIC.

In the case of network disable and NetworkManager enable, the network is started for the first time, and the network fails to read ifcfg-ethx file.

ifup: "[ -n "${DEVICE}" ] && is_nm_handling ${DEVICE} && exit 0" will exit 0.

if [ "$_use_nm" = "true" -a -n "$UUID" -a "$REALDEVICE" != "lo" ]; then
if [ "foo$2" = "fooboot" ] && [ "${TYPE}" = "Wireless" ]; then
exit 0
fi
[ -n "${DEVICE}" ] && is_nm_handling ${DEVICE} && exit 0
nmcli con up uuid "$UUID"
exit $?
fi

Drop MS_DNS* options from ipup-post

... if possible. These are related to PPP, and there's probably not much people using it these days anyway. Also, NetworkManager does not support these values neither.

  • Check what is actually using MS_DNS1 and MS_DNS2 these days.
  • Check if we can safely drop it.
  • Drop it from ipup-post.

[ANNOUNCEMENT] - Remove readonly-root

We are planning to remove readonly-root functionality from initscripts in near future. Since very similar functionality is delivered by recently introduced volatile-root in systemd v242

Reason being to encourage people to use volatile-root instead of legacy readonly-root. They are still some grey spots, which need further research from our side. We plan to make a guide how to move from readonly-root to volatile-root in near future.

We are now in planning phase and we are looking for your opinions, so don't hesitate to reach to us.

grep -L return value breaks network start

Spotted by M. W. on Mageia:

  • Noteworthy changes in release 3.2 (2018-12-20) [stable]
    ** Changes in behavior
    The --files-without-match (-L) option now causes grep to succeed
    when a file is listed, instead of when a line is selected. This
    resembles what git-grep does.

This breaks the init.d/network scripts there:

if LANG=C grep -EL "^ONBOOT=['\"]?[Nn][Oo]['\"]?" ifcfg-$i > /dev/null ;
then
# this loads the module, to preserve ordering
is_available $i
continue
fi

and just after for the # Bring up xDSL and VPN interfaces.

The fix is to either use a negation, or the negated option -l

Cheers,
Chris.

Shellcheck warnings

Most of the shellcheck warnings should be fixed (whenever possible) to make checking with shellcheck in the future more convenient. Right now, there are too many warnings, which can obfuscate new (problematic) warnings.

More PID collision avoidance, please

For a related issue, see https://bugzilla.kernel.org/show_bug.cgi?id=201441

The way the init scripts check for whether a server is running -- by getting a PID out of the pidfile and checking to see if a process with that PID is running -- is not foolproof. There is some attempt to reduce PID collision (the "-b binary" option), but I recently developed some init scripts where that particular collision avoidance was not effective.

My scripts had two issues that made PID collisions more likely:

  1. They started up several servers that were all multi-threaded. /etc/init.d/functions checks to see whether a process with a PID is running by testing for the existence of a directory /proc/PID. But it would appear that /proc also has sub-directories for LWPIDs. The LWPID directories are hidden -- they are not included if you get a listing of /proc -- but nevertheless, if you access them, they are there. This only increases the likelihood of PID collision: if you are checking whether a pid from the prior system boot is still running, you could get a false positive not only from a process with the same PID this boot, but also from a thread with an LWPID that matches the old PID. That particular occurrence of PID collision could be avoided by also checking if the LWPID matches the PID. If it does, it is the main thread, and still might be the PID of your server process. If the LWPID does not match the LWP's PID, it is not a main thread and is (almost?) certainly not the PID of your process.

  2. All my servers were java scripts. So the '-b binary' options helped not-at-all -- they all had the same binary: java. In order to avoid PID collision, I needed a way to distinguish servers from each other by using other options/arguments on their command line.

I've attached the /etc/init.d/functions that came with my system, and my mods that attempt to address these problems. I'm not entirely convinced that what I did is the ideal implementation, but I present them for your consideration. Do as you like with them.

functions.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.