├── .github ├── dependabot.yml └── workflows │ ├── codeql.yml │ ├── differential-pylint.yml │ ├── differential-shellcheck.yml │ └── integration_test.yml ├── .gitignore ├── .mergify.yml ├── .packit.yml ├── COPYING ├── Makefile ├── README.md ├── doc ├── examples │ ├── ifcfg-bond-802.3ad │ ├── ifcfg-bond-activebackup-arpmon │ ├── ifcfg-bond-activebackup-miimon │ ├── ifcfg-bond-slave │ ├── ifcfg-bridge │ ├── ifcfg-bridge-port │ ├── ifcfg-eth-alias │ ├── ifcfg-eth-dhcp │ ├── ifcfg-vlan │ └── static-routes-ipv6 └── sysconfig.txt ├── etc ├── rc.d │ └── init.d │ │ ├── functions │ │ └── network ├── rwtab ├── statetab └── sysconfig │ ├── netconsole │ ├── network-scripts │ └── readonly-root ├── initscripts.spec ├── man ├── consoletype.1 ├── genhostid.1 ├── ifup.8 ├── service.8 ├── usernetctl.8 └── usleep.1 ├── network-scripts ├── ifcfg-lo ├── ifdown ├── ifdown-bnep ├── ifdown-eth ├── ifdown-ippp ├── ifdown-ipv6 ├── ifdown-post ├── ifdown-routes ├── ifdown-sit ├── ifdown-tunnel ├── ifup ├── ifup-aliases ├── ifup-bnep ├── ifup-ctc ├── ifup-eth ├── ifup-ippp ├── ifup-ipv6 ├── ifup-plip ├── ifup-plusb ├── ifup-post ├── ifup-routes ├── ifup-sit ├── ifup-tunnel ├── ifup-wireless ├── init.ipv6-global ├── network-functions └── network-functions-ipv6 ├── po ├── .gitignore ├── Makefile ├── ar.po ├── as.po ├── bg.po ├── bn.po ├── bn_IN.po ├── bs.po ├── ca.po ├── cs.po ├── cy.po ├── da.po ├── de.po ├── el.po ├── en_GB.po ├── es.po ├── et.po ├── eu.po ├── fi.po ├── fr.po ├── fur.po ├── gl.po ├── gu.po ├── hi.po ├── hr.po ├── hu.po ├── id.po ├── initscripts.pot ├── is.po ├── it.po ├── ja.po ├── ka.po ├── kn.po ├── ko.po ├── lt.po ├── lv.po ├── mai.po ├── mk.po ├── ml.po ├── mr.po ├── ms.po ├── nb.po ├── nds.po ├── nl.po ├── nn.po ├── or.po ├── pa.po ├── pl.po ├── pt.po ├── pt_BR.po ├── ro.po ├── ru.po ├── si.po ├── sk.po ├── sl.po ├── sr.po ├── sr@latin.po ├── sv.po ├── ta.po ├── te.po ├── tr.po ├── uk.po ├── vi.po ├── xgettext_sh.py ├── zh_CN.po └── zh_TW.po ├── src ├── .gitignore ├── Makefile ├── build │ └── .gitkeep ├── consoletype.c ├── genhostid.c ├── rename_device.c ├── usernetctl.c └── usleep.c └── usr ├── lib ├── systemd │ └── system │ │ ├── import-state.service │ │ ├── loadmodules.service │ │ ├── netconsole.service │ │ └── readonly-root.service └── udev │ └── rules.d │ └── 60-net.rules ├── libexec ├── import-state ├── loadmodules ├── netconsole └── readonly-root └── sbin └── service /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: / 5 | schedule: 6 | interval: monthly 7 | labels: 8 | - 'type: dependencies' 9 | -------------------------------------------------------------------------------- /.github/workflows/codeql.yml: -------------------------------------------------------------------------------- 1 | # For most projects, this workflow file will not need changing; you simply need 2 | # to commit it to your repository. 3 | # 4 | # You may wish to alter this file to override the set of languages analyzed, 5 | # or to provide custom queries or build logic. 6 | # 7 | # ******** NOTE ******** 8 | # We have attempted to detect the languages in your repository. Please check 9 | # the `language` matrix defined below to confirm you have the correct set of 10 | # supported CodeQL languages. 11 | # 12 | name: "CodeQL" 13 | 14 | on: 15 | push: 16 | branches: [ main, rhel*-branch ] 17 | pull_request: 18 | # The branches below must be a subset of the branches above 19 | branches: [ main, rhel*-branch ] 20 | schedule: 21 | - cron: '39 11 * * 6' 22 | 23 | jobs: 24 | analyze: 25 | name: Analyze 26 | runs-on: ubuntu-latest 27 | permissions: 28 | actions: read 29 | contents: read 30 | security-events: write 31 | 32 | strategy: 33 | fail-fast: false 34 | matrix: 35 | language: [ 'cpp', 'python' ] 36 | # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ] 37 | # Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support 38 | 39 | steps: 40 | - name: Checkout repository 41 | uses: actions/checkout@v4 42 | 43 | # Initializes the CodeQL tools for scanning. 44 | - name: Initialize CodeQL 45 | uses: github/codeql-action/init@v3 46 | with: 47 | languages: ${{ matrix.language }} 48 | # If you wish to specify custom queries, you can do so here or in a config file. 49 | # By default, queries listed here will override any specified in a config file. 50 | # Prefix the list here with "+" to use these queries and those in the config file. 51 | 52 | # Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs 53 | # queries: security-extended,security-and-quality 54 | 55 | - name: Install dependencies 56 | if: ${{ matrix.language == 'cpp' }} 57 | run: sudo apt update && sudo apt install -y libpopt-dev gettext libglib2.0-dev 58 | 59 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 60 | # If this step fails, then you should remove it and run the build manually (see below) 61 | - name: Autobuild 62 | uses: github/codeql-action/autobuild@v3 63 | 64 | # ℹ️ Command-line programs to run using the OS shell. 65 | # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun 66 | 67 | # If the Autobuild fails above, remove it and uncomment the following three lines. 68 | # modify them (or add more) to build your code if your project, please refer to the EXAMPLE below for guidance. 69 | 70 | # - run: | 71 | # echo "Run, Build Application using script" 72 | # ./location_of_script_within_repo/buildscript.sh 73 | 74 | - name: Perform CodeQL Analysis 75 | uses: github/codeql-action/analyze@v3 76 | with: 77 | category: "/language:${{matrix.language}}" 78 | -------------------------------------------------------------------------------- /.github/workflows/differential-pylint.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: Differential PyLint 4 | 5 | on: 6 | pull_request: 7 | branches: [ main, rhel*-branch ] 8 | 9 | permissions: 10 | contents: read 11 | 12 | jobs: 13 | lint: 14 | runs-on: ubuntu-latest 15 | 16 | permissions: 17 | security-events: write 18 | 19 | steps: 20 | - name: Repository checkout 21 | uses: actions/checkout@v4 22 | 23 | - id: PyLint 24 | name: Differential PyLint 25 | uses: fedora-copr/vcs-diff-lint-action@v1 26 | 27 | - if: ${{ always() }} 28 | name: Upload artifact with detected PyLint defects in SARIF format 29 | uses: actions/upload-artifact@v4 30 | with: 31 | name: Differential PyLint SARIF 32 | path: ${{ steps.PyLint.outputs.sarif }} 33 | 34 | - if: ${{ failure() }} 35 | name: Upload SARIF to GitHub using github/codeql-action/upload-sarif 36 | uses: github/codeql-action/upload-sarif@v3 37 | with: 38 | sarif_file: ${{ steps.PyLint.outputs.sarif }} 39 | 40 | ... 41 | -------------------------------------------------------------------------------- /.github/workflows/differential-shellcheck.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | name: Differential ShellCheck 4 | 5 | on: 6 | push: 7 | pull_request: 8 | branches: [ main, rhel*-branch ] 9 | 10 | jobs: 11 | lint: 12 | runs-on: ubuntu-latest 13 | 14 | permissions: 15 | security-events: write 16 | 17 | steps: 18 | - name: Checkout 19 | uses: actions/checkout@v4 20 | with: 21 | fetch-depth: 0 22 | 23 | - id: ShellCheck 24 | name: Differential ShellCheck 25 | uses: redhat-plumbers-in-action/differential-shellcheck@v5 26 | with: 27 | token: ${{ secrets.GITHUB_TOKEN }} 28 | 29 | - if: ${{ always() }} 30 | name: Upload artifact with ShellCheck defects in SARIF format 31 | uses: actions/upload-artifact@v4 32 | with: 33 | name: Differential ShellCheck SARIF 34 | path: ${{ steps.ShellCheck.outputs.sarif }} 35 | 36 | ... 37 | -------------------------------------------------------------------------------- /.github/workflows/integration_test.yml: -------------------------------------------------------------------------------- 1 | name: Integration test 2 | on: 3 | push: 4 | branches: [ main ] 5 | pull_request: 6 | branches: [ main, rhel*-branch ] 7 | release: 8 | types: [ published, created ] 9 | 10 | jobs: 11 | buildCheck: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Repository checkout 15 | uses: actions/checkout@v4 16 | 17 | - name: Install dependencies 18 | run: sudo apt update && sudo apt install -y libpopt-dev gettext libglib2.0-dev 19 | 20 | - name: Build & install 21 | run: make all && make install DESTDIR=/tmp/initscripts 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ChangeLog 2 | *.tar.gz 3 | .vscode/ 4 | -------------------------------------------------------------------------------- /.mergify.yml: -------------------------------------------------------------------------------- 1 | # doc: https://docs.mergify.com 2 | --- 3 | 4 | pull_request_rules: 5 | 6 | - name: Automatic merge on approval & CI pass 7 | conditions: 8 | - "#approved-reviews-by>=1" 9 | - "#review-requested=0" 10 | - "#changes-requested-reviews-by=0" 11 | - check-success=buildCheck 12 | - check-success=lint 13 | - -draft 14 | - label!=dont-merge 15 | - -title~=(?i)wip 16 | - base=main 17 | actions: 18 | merge: 19 | method: rebase 20 | 21 | # --- --- Labels --- --- # 22 | 23 | - name: Add Fedora label 24 | conditions: 25 | - base=main 26 | actions: 27 | label: 28 | add: 29 | - Fedora 30 | 31 | - name: Remove Fedora label 32 | conditions: 33 | - base!=main 34 | actions: 35 | label: 36 | remove: 37 | - Fedora 38 | 39 | # --- # 40 | 41 | - name: Add RHEL8 label 42 | conditions: 43 | - base=rhel8-branch 44 | actions: 45 | label: 46 | add: 47 | - RHEL8 48 | 49 | - name: Remove RHEL8 label 50 | conditions: 51 | - base!=rhel8-branch 52 | actions: 53 | label: 54 | remove: 55 | - RHEL8 56 | 57 | # --- # 58 | 59 | - name: Add RHEL9 label 60 | conditions: 61 | - base=rhel9-branch 62 | actions: 63 | label: 64 | add: 65 | - RHEL9 66 | 67 | - name: Remove RHEL9 label 68 | conditions: 69 | - base!=rhel9-branch 70 | actions: 71 | label: 72 | remove: 73 | - RHEL9 74 | 75 | # --- # 76 | 77 | - name: Add network-scripts label 78 | conditions: 79 | - files~=^network-scripts/ 80 | actions: 81 | label: 82 | add: 83 | - network-scripts 84 | 85 | - name: Remove network-scripts label 86 | conditions: 87 | - -files~=^network-scripts/ 88 | actions: 89 | label: 90 | remove: 91 | - network-scripts 92 | 93 | # --- # 94 | 95 | - name: Add documentation label 96 | conditions: 97 | - or: 98 | - files~=^doc/ 99 | - files~=^po/ 100 | - files~=^man/ 101 | - files=README.md 102 | actions: 103 | label: 104 | add: 105 | - documentation 106 | 107 | - name: Remove documentation label 108 | conditions: 109 | - and: 110 | - -files~=^doc/ 111 | - -files~=^po/ 112 | - -files~=^man/ 113 | - -files=README.md 114 | actions: 115 | label: 116 | remove: 117 | - documentation 118 | 119 | # --- # 120 | 121 | - name: Add CI label 122 | conditions: 123 | - or: 124 | - files~=^.github/ 125 | - files~=.mergify.yml 126 | - files~=.packit.yml 127 | actions: 128 | label: 129 | add: 130 | - CI 131 | 132 | - name: Remove CI label 133 | conditions: 134 | - and: 135 | - -files~=^.github/ 136 | - -files~=.mergify.yml 137 | - -files~=.packit.yml 138 | actions: 139 | label: 140 | remove: 141 | - CI 142 | -------------------------------------------------------------------------------- /.packit.yml: -------------------------------------------------------------------------------- 1 | # doc: https://packit.dev/docs/ 2 | # config: https://packit.dev/docs/configuration/ 3 | --- 4 | 5 | specfile_path: initscripts.spec 6 | 7 | jobs: 8 | - &copr 9 | job: copr_build 10 | trigger: pull_request 11 | targets: 12 | - fedora-all 13 | - centos-stream-8-x86_64 14 | - centos-stream-9-x86_64 15 | 16 | - <<: *copr 17 | trigger: commit 18 | branch: main 19 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Basic Makefile for compiling & installing the files. 2 | # 3 | # Supports standard GNU Makefile variables for specifying the paths: 4 | # * prefix 5 | # * exec_prefix 6 | # * bindir 7 | # * sbindir 8 | # * libdir 9 | # * datarootdir 10 | # * datadir 11 | # * mandir 12 | # * sysconfdir 13 | # * localstatedir 14 | # * DESTDIR 15 | # 16 | 17 | SHELL = /bin/bash 18 | 19 | # Normally /usr/local is used. However, it does not make sense for us to use it 20 | # here, as it just complicates things even further. 21 | prefix = /usr 22 | exec_prefix = $(prefix) 23 | bindir = $(prefix)/bin 24 | sbindir = $(prefix)/sbin 25 | libdir = $(prefix)/lib 26 | libexecdir = $(exec_prefix)/libexec 27 | datarootdir = $(prefix)/share 28 | datadir = $(datarootdir) 29 | mandir = $(datadir)/man 30 | sysconfdir = /etc 31 | localstatedir = /var 32 | sharedstatedir = $(localstatedir)/lib 33 | 34 | VERSION := $(shell gawk '/Version:/ { print $$2 }' initscripts.spec) 35 | # NOTE: First check version type. We currently support two types: 36 | # * upstream version ##.## (e.g. 10.01) 37 | # * downstream version ##.##.## (e.g. 10.01.1) 38 | # Then based on type of version, increment last number by one using sed - https://stackoverflow.com/a/14348899 39 | NEXT_VERSION := $(shell grep -q "^Version:[ ]*[0-9]*\.[0-9]*$$" initscripts.spec && \ 40 | sed -nr 's/Version:[ ]*([0-9]*)\.([0-9]*)/echo "\1\.$$((\2+1))"/gep' initscripts.spec || \ 41 | sed -nr 's/Version:[ ]*([0-9]*)\.([0-9]*)\.([0-9]*)/echo "\1\.\2\.$$((\3+1))"/gep' initscripts.spec) 42 | 43 | 44 | all: make-binaries make-translations 45 | 46 | 47 | make-binaries: 48 | $(MAKE) -C src 49 | 50 | make-translations: 51 | $(MAKE) -C po PYTHON=$(PYTHON) 52 | 53 | 54 | # NOTE: We are no longer installing into /usr/sbin directory, because this is 55 | # just a symlink to /usr/bin, thanks to UsrMove change. Instead, we just 56 | # use virtual provides for /usr/sbin/ in specfile (for backward 57 | # compatibility). 58 | ifdef NO_NETWORK_SCRIPTS 59 | install: install-binaries install-translations install-etc install-usr install-man install-post 60 | else 61 | install: install-binaries install-translations install-etc-all install-usr install-network-scripts install-man-all install-post 62 | endif 63 | 64 | 65 | install-binaries: 66 | $(MAKE) install -C src DESTDIR=$(DESTDIR) prefix=$(prefix) bindir=$(bindir) libdir=$(libdir) 67 | 68 | install-translations: 69 | $(MAKE) install -C po DESTDIR=$(DESTDIR) prefix=$(prefix) bindir=$(bindir) libdir=$(libdir) \ 70 | datarootdir=$(datarootdir) datadir=$(datadir) sysconfdir=$(sysconfdir) 71 | 72 | install-etc-all: install-etc install-etc-network 73 | 74 | # NOTE: We are removing auxiliary symlink at the beginning. 75 | install-etc: 76 | rm -f etc/sysconfig/network-scripts 77 | install -m 0755 -d $(DESTDIR)$(sysconfdir) 78 | install -m 0755 -d $(DESTDIR)$(sysconfdir)/rc.d/init.d 79 | install -m 0755 -d $(DESTDIR)$(sysconfdir)/sysconfig 80 | install -m 0644 etc/rwtab $(DESTDIR)$(sysconfdir)/ 81 | install -m 0644 etc/statetab $(DESTDIR)$(sysconfdir)/ 82 | install -m 0644 etc/rc.d/init.d/functions $(DESTDIR)$(sysconfdir)/rc.d/init.d/ 83 | install -m 0644 etc/sysconfig/* $(DESTDIR)$(sysconfdir)/sysconfig/ 84 | 85 | install-etc-network: 86 | install -m 0755 -D etc/rc.d/init.d/network $(DESTDIR)$(sysconfdir)/rc.d/init.d/ 87 | 88 | install-usr: 89 | install -m 0755 -d $(DESTDIR)$(prefix) 90 | cp -a usr/* $(DESTDIR)$(prefix)/ 91 | 92 | install-network-scripts: install-usr install-etc 93 | install -m 0755 -d $(DESTDIR)$(sysconfdir)/sysconfig/network-scripts 94 | cp -a network-scripts/* $(DESTDIR)$(sysconfdir)/sysconfig/network-scripts/ 95 | ln -srf $(DESTDIR)$(sysconfdir)/sysconfig/network-scripts/{ifup-ippp,ifup-isdn} 96 | ln -srf $(DESTDIR)$(sysconfdir)/sysconfig/network-scripts/{ifdown-ippp,ifdown-isdn} 97 | 98 | install-man-all: install-man install-network-scripts-man 99 | 100 | install-man: install-usr 101 | install -m 0755 -d $(DESTDIR)$(mandir)/man1 102 | install -m 0755 -d $(DESTDIR)$(mandir)/man8 103 | install -m 0644 man/consoletype.1 $(DESTDIR)$(mandir)/man1 104 | install -m 0644 man/genhostid.1 $(DESTDIR)$(mandir)/man1 105 | install -m 0644 man/usleep.1 $(DESTDIR)$(mandir)/man1 106 | install -m 0644 man/service.8 $(DESTDIR)$(mandir)/man8 107 | 108 | install-network-scripts-man: 109 | install -m 0644 man/ifup.8 $(DESTDIR)$(mandir)/man8 110 | install -m 0644 man/usernetctl.8 $(DESTDIR)$(mandir)/man8 111 | 112 | # Initscripts still ship some empty directories necessary for system to function 113 | # correctly... 114 | install-post: install-etc 115 | install -m 0755 -d $(DESTDIR)$(sysconfdir)/sysconfig/console 116 | install -m 0755 -d $(DESTDIR)$(sysconfdir)/sysconfig/modules 117 | install -m 0755 -d $(DESTDIR)$(sharedstatedir)/stateless/state 118 | install -m 0755 -d $(DESTDIR)$(sharedstatedir)/stateless/writable 119 | install -m 0755 -d $(DESTDIR)$(libexecdir)/initscripts/legacy-actions 120 | for idx in {0..6}; do \ 121 | dir=$(DESTDIR)$(sysconfdir)/rc.d/rc$$idx.d; \ 122 | install -m 0755 -d $$dir; \ 123 | ln -srf $(DESTDIR)$(sysconfdir)/rc.d/rc$$idx.d $(DESTDIR)$(sysconfdir)/; \ 124 | done 125 | ln -srf $(DESTDIR)$(sysconfdir)/rc.d/init.d $(DESTDIR)$(sysconfdir)/init.d 126 | 127 | clean: 128 | $(MAKE) clean -C src 129 | $(MAKE) clean -C po 130 | @find . -name "*~" -exec rm -v -f {} \; 131 | 132 | tag: 133 | @git tag -a -f -m "$(VERSION) release" $(VERSION) 134 | @echo "Tagged as $(VERSION)" 135 | 136 | release-commit: 137 | @git log --decorate=no --format="- %s" $(VERSION)..HEAD > .changelog.tmp 138 | @rpmdev-bumpspec -D -n $(NEXT_VERSION) -f .changelog.tmp initscripts.spec 139 | @rm -f .changelog.tmp 140 | @git add initscripts.spec 141 | @git commit --message="$(NEXT_VERSION)" 142 | @echo -e "\n New release commit ($(NEXT_VERSION)) created:\n" 143 | @git show 144 | 145 | archive: clean 146 | @git archive --format=tar --prefix=initscripts-$(VERSION)/ HEAD > initscripts-$(VERSION).tar 147 | @mkdir -p initscripts-$(VERSION)/ 148 | @tar --append -f initscripts-$(VERSION).tar initscripts-$(VERSION) 149 | @gzip -f initscripts-$(VERSION).tar 150 | @rm -rf initscripts-$(VERSION) 151 | @echo "The archive is at initscripts-$(VERSION).tar.gz" 152 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # initscripts 2 | 3 | [![Build Status](https://github.com/fedora-sysv/initscripts/workflows/Integration%20test/badge.svg)](https://github.com/fedora-sysv/initscripts/actions?query=workflow%3AIntegration+test) [![Differential ShellCheck](https://github.com/fedora-sysv/initscripts/actions/workflows/differential-shellcheck.yml/badge.svg)](https://github.com/fedora-sysv/initscripts/actions/workflows/differential-shellcheck.yml) [![Differential ShellCheck](https://github.com/fedora-sysv/initscripts/actions/workflows/differential-shellcheck.yml/badge.svg)](https://github.com/fedora-sysv/initscripts/actions/workflows/differential-shellcheck.yml) [![CodeQL](https://github.com/fedora-sysv/initscripts/actions/workflows/codeql.yml/badge.svg)](https://github.com/fedora-sysv/initscripts/actions/workflows/codeql.yml) [![Mergify Status][mergify-status]][mergify] 4 | 5 | [mergify]: https://mergify.com 6 | [mergify-status]: https://img.shields.io/endpoint.svg?url=https://api.mergify.com/v1/badges/fedora-sysv/initscripts&style=flat 7 | 8 | This repository contains source code for **legacy** *System V [initscripts](https://en.wikipedia.org/wiki/Init)*, 9 | which are primarily used in *[Linux](https://en.wikipedia.org/wiki/Linux) distributions like e.g.*: 10 | 11 | * [Fedora](https://en.wikipedia.org/wiki/Fedora_(operating_system)) 12 | * [Red Hat Enterprise Linux](https://en.wikipedia.org/wiki/Red_Hat_Enterprise_Linux) 13 | * [CentOS](https://en.wikipedia.org/wiki/CentOS) 14 | * and some others as well... 15 | 16 | Since most of the major Linux distributions have already switched to 17 | *[systemd](https://en.wikipedia.org/wiki/Systemd)*, the *initscripts concept* is 18 | quite outdated nowadays. *As a result, this repository provides primarily only 19 | the support for other initscripts that might still exist out there.* 20 | 21 | The above mentioned support includes e.g. the 22 | [`/etc/rc.d/init.d/functions`](https://github.com/fedora-sysv/initscripts/blob/main/etc/rc.d/init.d/functions) 23 | or 24 | [`/usr/sbin/service`](https://github.com/fedora-sysv/initscripts/blob/main/usr/sbin/service) 25 | files. 26 | 27 | Another functionality this source code provides includes: 28 | 29 | * [`network-scripts`](https://github.com/fedora-sysv/initscripts/tree/main/network-scripts) - **legacy** scripts for manipulating of network devices 30 | * [`readonly-root`](https://github.com/fedora-sysv/initscripts/blob/main/usr/lib/systemd/readonly-root) - service for configuring the read-only root support 31 | * [`netconsole`](https://github.com/fedora-sysv/initscripts/blob/main/etc/rc.d/init.d/netconsole) - service for initializing of network console logging 32 | 33 | For the *[RPM](https://en.wikipedia.org/wiki/Rpm_(software))* based distributions 34 | we also provide a [`specfile`](https://github.com/fedora-sysv/initscripts/blob/main/initscripts.spec) 35 | for easier packaging. 36 | 37 | ## Future of initscripts 38 | 39 | As mentioned above, the *initscripts concept* is outdated nowadays, and de-facto 40 | obsolete. Most of the work on this repository is just a maintenance, and we do 41 | **not** plan on extending the support for initscripts in the future in any way. 42 | 43 | We intend to convert the rest of the remaining services into *systemd* units, 44 | and remove them eventually if possible. 45 | 46 | And we have also started our work on decomissioning of 47 | [`network-scripts`](https://github.com/fedora-sysv/initscripts/tree/main/network-scripts) 48 | as well. This means no new functionality will be added into them. In case you 49 | need some you should ask for it to be implemented 50 | in *[NetworkManager](https://en.wikipedia.org/wiki/NetworkManager)*, if it isn't 51 | already. 52 | 53 | ## No longer active branches 54 | 55 | Follow the steps in our wiki - 56 | [how to access inactive branches](https://github.com/fedora-sysv/initscripts/wiki/How-to-access-inactive-branches) - 57 | in case you need to check out old git branches for any reason. 58 | 59 | 98 | 99 | ## Bugs reporting 100 | 101 | If you find a bug, we would like to hear about it -- although we can't guarantee 102 | we will be able to fix it... The best way to report bugs differs for each 103 | distribution: 104 | 105 | * `RHEL | CentOS` - create a bug report in [bugzilla](https://bugzilla.redhat.com/enter_bug.cgi) for corresponding RHEL version 106 | * `Fedora | Other` - create a [new issue](https://github.com/fedora-sysv/initscripts/issues/new) directly here on GitHub 107 | 108 | **NOTE:** Bug reports created for *Fedora* in [bugzilla](https://bugzilla.redhat.com/) usually take a lot of time to 109 | resolve. *We advise to use GitHub instead.* 110 | -------------------------------------------------------------------------------- /doc/examples/ifcfg-bond-802.3ad: -------------------------------------------------------------------------------- 1 | # ifcfg sample for bond in mode 4/802.3ad 2 | # with static networking configuration 3 | # lacp_rate=1 for fast LACPDU rx rate (optional) 4 | # 5 | # Please read /usr/share/doc/initscripts-*/sysconfig.txt 6 | # for the documentation of these parameters. 7 | 8 | DEVICE=bond0 9 | ONBOOT=yes 10 | USERCTL=no 11 | TYPE=Ethernet 12 | BOOTPROTO=none 13 | BONDING_OPTS="mode=4 lacp_rate=1" 14 | IPADDR=192.168.1.4 15 | NETMASK=255.255.255.0 16 | GATEWAY=192.168.1.1 17 | -------------------------------------------------------------------------------- /doc/examples/ifcfg-bond-activebackup-arpmon: -------------------------------------------------------------------------------- 1 | # ifcfg sample for bond in active-backup mode using 2 | # ARP monitoring. The ARP probes frequency (arp_interval) 3 | # is 500ms and the target IP address (arp_ip_target) 4 | # is 192.168.1.1 5 | # 6 | # Please read /usr/share/doc/initscripts-*/sysconfig.txt 7 | # for the documentation of these parameters. 8 | 9 | DEVICE=bond0 10 | ONBOOT=yes 11 | USERCTL=no 12 | TYPE=Ethernet 13 | BOOTPROTO=none 14 | BONDING_OPTS="mode=1 arp_interval=500 arp_ip_target=192.168.1.1" 15 | IPADDR=192.168.1.4 16 | NETMASK=255.255.255.0 17 | GATEWAY=192.168.1.1 18 | -------------------------------------------------------------------------------- /doc/examples/ifcfg-bond-activebackup-miimon: -------------------------------------------------------------------------------- 1 | # ifcfg sample for bond in active-backup mode using 2 | # MII link monitoring. The MII status polling frequency 3 | # (miimon) is 500ms. 4 | # 5 | # Please read /usr/share/doc/initscripts-*/sysconfig.txt 6 | # for the documentation of these parameters. 7 | 8 | DEVICE=bond0 9 | ONBOOT=yes 10 | USERCTL=no 11 | TYPE=Ethernet 12 | BOOTPROTO=none 13 | BONDING_OPTS="mode=1 miimon=500" 14 | IPADDR=192.168.1.4 15 | NETMASK=255.255.255.0 16 | GATEWAY=192.168.1.1 17 | -------------------------------------------------------------------------------- /doc/examples/ifcfg-bond-slave: -------------------------------------------------------------------------------- 1 | # ifcfg sample for bond slave device 2 | # 3 | # Please read /usr/share/doc/initscripts-*/sysconfig.txt 4 | # for the documentation of these parameters. 5 | 6 | DEVICE=eth0 7 | TYPE=Ethernet 8 | USERCTL=no 9 | SLAVE=yes 10 | MASTER=bond0 11 | BOOTPROTO=none 12 | HWADDR=AA:BB:CC:DD:EE:FF 13 | -------------------------------------------------------------------------------- /doc/examples/ifcfg-bridge: -------------------------------------------------------------------------------- 1 | # ifcfg sample for linux bridge device with IP address. 2 | # 3 | # Please read /usr/share/doc/initscripts-*/sysconfig.txt 4 | # for the documentation of these parameters. 5 | 6 | DEVICE=br0 7 | TYPE=Bridge 8 | IPADDR=192.168.1.1 9 | NETMASK=255.255.255.0 10 | ONBOOT=yes 11 | BOOTPROTO=none 12 | DELAY=0 13 | -------------------------------------------------------------------------------- /doc/examples/ifcfg-bridge-port: -------------------------------------------------------------------------------- 1 | # ifcfg sample for a device that is a linux bridge port 2 | # 3 | # Please read /usr/share/doc/initscripts-*/sysconfig.txt 4 | # for the documentation of these parameters. 5 | 6 | DEVICE=eth1 7 | HWADDR=00:11:22:33:44:55 8 | ONBOOT=yes 9 | BRIDGE=br0 10 | -------------------------------------------------------------------------------- /doc/examples/ifcfg-eth-alias: -------------------------------------------------------------------------------- 1 | # ifcfg sample for alias interface on top of eth0 2 | # 3 | # Please read /usr/share/doc/initscripts-*/sysconfig.txt 4 | # for the documentation of these parameters. 5 | 6 | DEVICE=eth0:0 7 | BOOTPROTO=none 8 | IPADDR=192.168.1.1 9 | NETMASK=255.255.255.0 10 | ONBOOT=yes 11 | USERCTL=no 12 | 13 | -------------------------------------------------------------------------------- /doc/examples/ifcfg-eth-dhcp: -------------------------------------------------------------------------------- 1 | # ifcfg sample for common ethernet interfaces using DHCP 2 | # 3 | # Please read /usr/share/doc/initscripts-*/sysconfig.txt 4 | # for the documentation of these parameters. 5 | 6 | DEVICE=eth0 7 | BOOTPROTO=dhcp 8 | HWADDR=00:11:22:33:44:55 9 | ONBOOT=yes 10 | 11 | # WARNING: When both DHCP_HOSTNAME and DHCP_FQDN are specified, 12 | # only DHCP_FQDN will be used. 13 | DHCP_HOSTNAME=host1 14 | DHCP_FQDN=host1.foo.bar.com 15 | -------------------------------------------------------------------------------- /doc/examples/ifcfg-vlan: -------------------------------------------------------------------------------- 1 | # ifcfg sample for a VLAN device (vlanid=122) on top of 2 | # eth0 device using static IP configuration 3 | # 4 | # Please read /usr/share/doc/initscripts-*/sysconfig.txt 5 | # for the documentation of these parameters. 6 | 7 | TYPE=Ethernet 8 | DEVICE=eth0.122 9 | VLAN=yes 10 | BOOTPROTO=none 11 | NETMASK=255.255.255.0 12 | IPADDR=192.168.1.1 13 | 14 | -------------------------------------------------------------------------------- /doc/examples/static-routes-ipv6: -------------------------------------------------------------------------------- 1 | # Version: 2002-01-09 2 | 3 | # file: /etc/sysconfig/static-routes-ipv6 4 | # 5 | # description: this file contains all static IPv6 routes 6 | # description: Here you can specify several routes to specified gateways 7 | # description: and also route through a virtual tunnel interface 8 | # 9 | # (P) 2000-2002 by Peter Bieringer 10 | 11 | #Device IPv6 network to route IPv6 gateway address 12 | 13 | ## Example: static routes through a gateway on local link 14 | #eth0 fec0:0:0:2::/64 fec0:0:0:1:0:0:0:20 15 | #eth0 3ffe:ffff:1234::/48 3ffe:ffff:1234:0002:0:0:0:1 16 | 17 | ## Example: default route through a gateway on local link 18 | #eth0 2000::/3 3ffe:ffff:1234:0002:0:0:0:1 19 | 20 | ## Example: static route through a dedicated tunnel 21 | #sit1 3ffe:ffff:1234::/48 22 | -------------------------------------------------------------------------------- /etc/rc.d/init.d/network: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # network Bring up/down networking 4 | # 5 | # chkconfig: - 10 90 6 | # description: Activates/Deactivates all network interfaces configured to \ 7 | # start at boot time. 8 | # 9 | ### BEGIN INIT INFO 10 | # Provides: $network 11 | # Should-Start: iptables ip6tables NetworkManager-wait-online NetworkManager $network-pre 12 | # Short-Description: Bring up/down networking 13 | # Description: Bring up/down networking 14 | ### END INIT INFO 15 | 16 | # Source function library. 17 | . /etc/init.d/functions 18 | 19 | if [ ! -f /etc/sysconfig/network ]; then 20 | exit 6 21 | fi 22 | 23 | . /etc/sysconfig/network 24 | 25 | if [ -f /etc/sysconfig/pcmcia ]; then 26 | . /etc/sysconfig/pcmcia 27 | fi 28 | 29 | 30 | # Check that networking is up. 31 | is_false "${NETWORKING}" && exit 6 32 | 33 | # if the ip configuration utility isn't around we can't function. 34 | [ -x /sbin/ip ] || exit 1 35 | 36 | 37 | CWD=$(pwd) 38 | cd /etc/sysconfig/network-scripts 39 | 40 | . ./network-functions 41 | 42 | # find all the interfaces besides loopback. 43 | # ignore aliases, alternative configurations, and editor backup files 44 | interfaces=$(ls ifcfg-* | \ 45 | LC_ALL=C sed -e "$__sed_discard_ignored_files" \ 46 | -e '/\(ifcfg-lo$\|:\|ifcfg-.*-range\)/d' \ 47 | -e '{ s/^ifcfg-//g;s/[0-9]/ &/}' | \ 48 | LC_ALL=C sort -k 1,1 -k 2n | \ 49 | LC_ALL=C sed 's/ //') 50 | rc=0 51 | 52 | net_log $"You are using 'network' service provided by 'network-scripts', which are now deprecated." warning network >&2 53 | net_log $"'network-scripts' will be removed from distribution in near future." warning network >&2 54 | net_log $"It is advised to switch to 'NetworkManager' instead for network management." warning network >&2 55 | 56 | # This disables additional warnings during the boot process: 57 | export DEPRECATION_WARNING_ISSUED='true' 58 | 59 | # See how we were called. 60 | case "$1" in 61 | start) 62 | [ "$EUID" != "0" ] && exit 4 63 | rc=0 64 | # IPv6 hook (pre IPv4 start) 65 | if [ -x /etc/sysconfig/network-scripts/init.ipv6-global ]; then 66 | /etc/sysconfig/network-scripts/init.ipv6-global start pre 67 | fi 68 | 69 | apply_sysctl 70 | 71 | #tell NM to reload its configuration 72 | if [ "$(LANG=C nmcli -t --fields running general status 2>/dev/null)" = "running" ]; then 73 | nmcli connection reload 74 | fi 75 | 76 | # bring up loopback interface 77 | action $"Bringing up loopback interface: " ./ifup ifcfg-lo 78 | 79 | if is_true "$VLAN" ; then 80 | if [ ! -d /proc/net/vlan ] && ! modprobe 8021q >/dev/null 2>&1 ; then 81 | net_log $"No 802.1Q VLAN support available in kernel." 82 | fi 83 | fi 84 | 85 | vlaninterfaces="" 86 | vpninterfaces="" 87 | xdslinterfaces="" 88 | bridgeinterfaces="" 89 | 90 | # bring up all other interfaces configured to come up at boot time 91 | for i in $interfaces; do 92 | unset DEVICE TYPE SLAVE NM_CONTROLLED 93 | eval $(LANG=C grep -F "DEVICE=" ifcfg-$i) 94 | eval $(LANG=C grep -F "TYPE=" ifcfg-$i) 95 | eval $(LANG=C grep -F "SLAVE=" ifcfg-$i) 96 | eval $(LANG=C grep -F "NM_CONTROLLED=" ifcfg-$i) 97 | 98 | if [ -z "$DEVICE" ] ; then DEVICE="$i"; fi 99 | 100 | if is_true "$SLAVE" && ( ! is_nm_running || is_false "$NM_CONTROLLED" ) ; then 101 | continue 102 | fi 103 | 104 | if [ "${DEVICE##cipcb}" != "$DEVICE" ] ; then 105 | vpninterfaces="$vpninterfaces $i" 106 | continue 107 | fi 108 | if [ "$TYPE" = "xDSL" -o "$TYPE" = "Modem" ]; then 109 | xdslinterfaces="$xdslinterfaces $i" 110 | continue 111 | fi 112 | 113 | if [ "$TYPE" = "Bridge" ]; then 114 | bridgeinterfaces="$bridgeinterfaces $i" 115 | continue 116 | fi 117 | if [ "$TYPE" = "IPSEC" ] || [ "$TYPE" = "IPIP" ] || [ "$TYPE" = "GRE" ]; then 118 | vpninterfaces="$vpninterfaces $i" 119 | continue 120 | fi 121 | 122 | if [ "${DEVICE%%.*}" != "$DEVICE" -o "${DEVICE##vlan}" != "$DEVICE" ] ; then 123 | vlaninterfaces="$vlaninterfaces $i" 124 | continue 125 | fi 126 | 127 | if ( . ./ifcfg-"$i" ; is_false "$ONBOOT" ) ; then 128 | # this loads the module, to preserve ordering 129 | is_available $i 130 | continue 131 | fi 132 | action $"Bringing up interface $i: " ./ifup $i boot 133 | [ $? -ne 0 ] && rc=1 134 | done 135 | 136 | # Bring up xDSL and VPN interfaces 137 | for i in $vlaninterfaces $bridgeinterfaces $xdslinterfaces $vpninterfaces ; do 138 | if ( . ./ifcfg-"$i" ; ! is_false "$ONBOOT" ) ; then 139 | action $"Bringing up interface $i: " ./ifup $i boot 140 | [ $? -ne 0 ] && rc=1 141 | fi 142 | done 143 | 144 | # Add non interface-specific static-routes. 145 | if [ -f /etc/sysconfig/static-routes ]; then 146 | if [ -x /sbin/route ]; then 147 | grep "^any" /etc/sysconfig/static-routes | while read ignore args ; do 148 | /sbin/route add -$args 149 | done 150 | else 151 | net_log $"Legacy static-route support not available: /sbin/route not found" 152 | fi 153 | fi 154 | 155 | # IPv6 hook (post IPv4 start) 156 | if [ -x /etc/sysconfig/network-scripts/init.ipv6-global ]; then 157 | /etc/sysconfig/network-scripts/init.ipv6-global start post 158 | fi 159 | # Run this again to catch any interface-specific actions 160 | apply_sysctl 161 | 162 | touch /var/lock/subsys/network 163 | 164 | # Fixed delay 165 | [ -n "${NETWORKDELAY}" ] && [ -z "${WAIT_UNTIL_REACHABLE}" ] && /bin/sleep "${NETWORKDELAY}" 166 | 167 | # Adaptive delay 168 | # It tests if network connection is ready via ping 169 | if [ -n "${WAIT_UNTIL_REACHABLE}" ] ; then 170 | [ -z "${NETWORKDELAY}" ] && NETWORKDELAY=30 171 | TIMEOUT=0 172 | IPV="" 173 | ipcalc -c -6 "${WAIT_UNTIL_REACHABLE}" &>/dev/null && IPV="-6" 174 | while [ $TIMEOUT -le $NETWORKDELAY ] ; do 175 | ping $IPV -q -c 1 -W 1 "${WAIT_UNTIL_REACHABLE}" >/dev/null && break 176 | TIMEOUT=$(( TIMEOUT + 1 )) 177 | done 178 | [ $TIMEOUT -gt $NETWORKDELAY ] && net_log $"Target is not reachable, but timeout was already reached. Continuing anyway." 179 | fi 180 | ;; 181 | stop) 182 | [ "$EUID" != "0" ] && exit 4 183 | # Don't shut the network down if root or /usr is on NFS or a network 184 | # block device. 185 | root_fstype=$(gawk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/" && $3 != "rootfs") { print $3; }}' /proc/mounts) 186 | usr_fstype=$(gawk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/usr" && $3 != "rootfs") { print $3; }}' /proc/mounts) 187 | 188 | if [[ "${root_fstype}" == nfs* || "${usr_fstype}" == nfs* ]] || systemctl show --property=RequiredBy -- -.mount usr.mount | grep -q 'remote-fs.target' ; then 189 | net_log $"rootfs or /usr is on network filesystem, leaving network up" 190 | exit 1 191 | fi 192 | 193 | unset root_fstype usr_fstype 194 | 195 | # Don't shut the network down when shutting down the system if configured 196 | # as such in sysconfig 197 | if is_false "$IFDOWN_ON_SHUTDOWN"; then 198 | if systemctl is-system-running | grep -q 'stopping'; then 199 | net_log $"system is shutting down, leaving interfaces up as requested" info 200 | exit 0 201 | fi 202 | fi 203 | 204 | vlaninterfaces="" 205 | vpninterfaces="" 206 | xdslinterfaces="" 207 | bridgeinterfaces="" 208 | remaining="" 209 | rc=0 210 | 211 | # get list of bonding, vpn, and xdsl interfaces 212 | for i in $interfaces; do 213 | unset DEVICE TYPE 214 | eval $(LANG=C grep -F "DEVICE=" ifcfg-$i) 215 | eval $(LANG=C grep -F "TYPE=" ifcfg-$i) 216 | 217 | if [ -z "$DEVICE" ] ; then DEVICE="$i"; fi 218 | 219 | if [ "${DEVICE##cipcb}" != "$DEVICE" ] ; then 220 | vpninterfaces="$vpninterfaces $i" 221 | continue 222 | fi 223 | if [ "$TYPE" = "IPSEC" ] || [ "$TYPE" = "IPIP" ] || [ "$TYPE" = "GRE" ]; then 224 | vpninterfaces="$vpninterfaces $i" 225 | continue 226 | fi 227 | if [ "$TYPE" = "Bridge" ]; then 228 | bridgeinterfaces="$bridgeinterfaces $i" 229 | continue 230 | fi 231 | if [ "$TYPE" = "xDSL" -o "$TYPE" = "Modem" ]; then 232 | xdslinterfaces="$xdslinterfaces $i" 233 | continue 234 | fi 235 | 236 | if [ "${DEVICE%%.*}" != "$DEVICE" -o "${DEVICE##vlan}" != "$DEVICE" ] ; then 237 | vlaninterfaces="$vlaninterfaces $i" 238 | continue 239 | fi 240 | remaining="$remaining $i" 241 | done 242 | 243 | for i in $vpninterfaces $xdslinterfaces $bridgeinterfaces $vlaninterfaces $remaining; do 244 | unset DEVICE TYPE 245 | (. ./ifcfg-$i 246 | if [ -z "$DEVICE" ] ; then DEVICE="$i"; fi 247 | 248 | if ! check_device_down $DEVICE; then 249 | action $"Shutting down interface $i: " ./ifdown $i boot 250 | [ $? -ne 0 ] && rc=1 251 | fi 252 | ) 253 | done 254 | 255 | action $"Shutting down loopback interface: " ./ifdown ifcfg-lo 256 | 257 | sysctl -w net.ipv4.ip_forward=0 > /dev/null 2>&1 258 | 259 | # IPv6 hook (post IPv4 stop) 260 | if [ -x /etc/sysconfig/network-scripts/init.ipv6-global ]; then 261 | /etc/sysconfig/network-scripts/init.ipv6-global stop post 262 | fi 263 | 264 | rm -f /var/lock/subsys/network 265 | ;; 266 | status) 267 | echo $"Configured devices:" 268 | echo lo $interfaces 269 | 270 | echo $"Currently active devices:" 271 | echo $(/sbin/ip -o link show up | awk -F ": " '{ print $2 }') 272 | ;; 273 | restart|force-reload) 274 | cd "$CWD" 275 | $0 stop 276 | $0 start 277 | rc=$? 278 | ;; 279 | *) 280 | echo $"Usage: $0 {start|stop|status|restart|force-reload}" 281 | exit 2 282 | esac 283 | 284 | exit $rc 285 | -------------------------------------------------------------------------------- /etc/rwtab: -------------------------------------------------------------------------------- 1 | dirs /var/cache/man 2 | dirs /var/gdm 3 | dirs /var/lib/xkb 4 | dirs /var/log 5 | dirs /var/lib/puppet 6 | dirs /var/lib/dbus 7 | dirs /var/lib/mlocate 8 | dirs /var/lib/systemd/rfkill 9 | 10 | empty /tmp 11 | empty /var/cache/foomatic 12 | empty /var/cache/logwatch 13 | empty /var/cache/httpd/ssl 14 | empty /var/cache/httpd/proxy 15 | empty /var/cache/php-pear 16 | empty /var/cache/systemtap 17 | empty /var/db/nscd 18 | empty /var/lib/dav 19 | empty /var/lib/dhcpd 20 | empty /var/lib/dhclient 21 | empty /var/lib/php 22 | empty /var/lib/pulse 23 | empty /var/lib/systemd/timers 24 | empty /var/lib/ups 25 | empty /var/lib/chrony 26 | empty /var/tmp 27 | 28 | files /etc/adjtime 29 | files /etc/ntp.conf 30 | files /etc/resolv.conf 31 | files /etc/lvm/cache 32 | files /etc/lvm/archive 33 | files /etc/lvm/backup 34 | files /var/account 35 | files /var/lib/arpwatch 36 | files /var/lib/NetworkManager 37 | files /var/cache/alchemist 38 | files /var/lib/gdm 39 | files /var/lib/iscsi 40 | files /var/lib/logrotate.status 41 | files /var/lib/ntp 42 | files /var/lib/xen 43 | files /var/empty/sshd/etc/localtime 44 | files /var/lib/systemd/random-seed 45 | files /var/spool 46 | files /var/lib/samba 47 | files /var/log/audit/audit.log 48 | files /var/lib/nfs 49 | -------------------------------------------------------------------------------- /etc/statetab: -------------------------------------------------------------------------------- 1 | # 2 | # A list of paths which should be bind-mounted from a 3 | # partition dedicated to persistent data 4 | # 5 | # See $STATE_LABEL in /etc/sysconfig/readonly-root 6 | # 7 | # Examples: 8 | # 9 | # /root 10 | # /etc/ssh 11 | # /var/spool/mail 12 | # 13 | -------------------------------------------------------------------------------- /etc/sysconfig/netconsole: -------------------------------------------------------------------------------- 1 | # This is the configuration file for the netconsole service. By starting 2 | # this service you allow a remote syslog daemon to record console output 3 | # from this system. 4 | 5 | # The local port number that the netconsole module will use 6 | # LOCALPORT=6666 7 | 8 | # The ethernet device to send console messages out of (only set this if it 9 | # can't be automatically determined) 10 | # DEV= 11 | 12 | # The IP address of the remote syslog server to send messages to 13 | # SYSLOGADDR= 14 | 15 | # The listening port of the remote syslog daemon 16 | # SYSLOGPORT=514 17 | 18 | # The MAC address of the remote syslog server (only set this if it can't 19 | # be automatically determined) 20 | # SYSLOGMACADDR= 21 | -------------------------------------------------------------------------------- /etc/sysconfig/network-scripts: -------------------------------------------------------------------------------- 1 | ../../network-scripts -------------------------------------------------------------------------------- /etc/sysconfig/readonly-root: -------------------------------------------------------------------------------- 1 | # Set to 'yes' to mount the system filesystems read-only. 2 | # NOTE: It's necessary to append 'ro' to mount options of '/' mount point in 3 | # /etc/fstab as well, otherwise the READONLY option will not work. 4 | READONLY=no 5 | # Set to 'yes' to mount various temporary state as either tmpfs 6 | # or on the block device labelled RW_LABEL. Implied by READONLY 7 | TEMPORARY_STATE=no 8 | # Place to put a tmpfs for temporary scratch writable space 9 | RW_MOUNT=/var/lib/stateless/writable 10 | # Label on local filesystem which can be used for temporary scratch space 11 | RW_LABEL=stateless-rw 12 | # Options to use for temporary mount 13 | RW_OPTIONS= 14 | # Label for partition with persistent data 15 | STATE_LABEL=stateless-state 16 | # Where to mount to the persistent data 17 | STATE_MOUNT=/var/lib/stateless/state 18 | # Options to use for persistent mount 19 | STATE_OPTIONS= 20 | # NFS server to use for persistent data? 21 | CLIENTSTATE= 22 | # Use slave bind-mounts 23 | SLAVE_MOUNTS=yes 24 | -------------------------------------------------------------------------------- /man/consoletype.1: -------------------------------------------------------------------------------- 1 | .TH CONSOLETYPE 1 "Red Hat, Inc" "RH" \" -*- nroff -*- 2 | .SH NAME 3 | \fBconsoletype 4 | \- print type of the console connected to standard input 5 | .SH SYNOPSIS 6 | \fBconsoletype [\fIstdout\fR] [\fIfg\fR] 7 | .SH DESCRIPTION 8 | \fBconsoletype 9 | prints the type of console connected to standard input, and checks 10 | whether the console connected to standard input is the current 11 | foreground virtual console. With no arguments, it prints 12 | \fIvt\fR 13 | if console is a virtual terminal (/dev/tty* or /dev/console device if not on 14 | a serial console), 15 | \fIserial\fR 16 | if standard input is a serial console (/dev/console or /dev/ttyS*) and 17 | \fIpty\fR 18 | if standard input is a pseudo terminal. 19 | .SH RETURN VALUE 20 | \fBconsoletype 21 | when passed no arguments returns 22 | .TP 23 | \fI0 24 | if on virtual terminal 25 | .TP 26 | \fI1 27 | if on serial console 28 | .TP 29 | \fI2 30 | if on a pseudo terminal. 31 | .TP 32 | When passed the \fIstdout\fR argument, \fBconsoletype\fR returns 33 | .TP 34 | \fI0 35 | in all cases, and prints the console type to stdout. 36 | .TP 37 | When passed the \fIfg\fR argument, \fBconsoletype\fR returns 38 | .TP 39 | \fI0 40 | if the console connected to standard input is the current virtual 41 | terminal 42 | .TP 43 | \fI1 44 | otherwise. 45 | -------------------------------------------------------------------------------- /man/genhostid.1: -------------------------------------------------------------------------------- 1 | .TH GENHOSTID 1 2 | .SH NAME 3 | genhostid \- generate and set a hostid for the current host 4 | .SH SYNOPSIS 5 | .B genhostid 6 | 7 | .SH DESCRIPTION 8 | \fBgenhostid\fR generates a random hostid and stores it in /etc/hostid, 9 | if /etc/hostid does not already exist. 10 | 11 | .SH "SEE ALSO" 12 | hostid(1), gethostid(2), sethostid(2) 13 | -------------------------------------------------------------------------------- /man/ifup.8: -------------------------------------------------------------------------------- 1 | .\" Copyright 2009 Petr Lautrbach (plautrba@redhat.com) 2 | .TH ifup 8 2009-10-27 "" "System Administration tools and Daemons" 3 | .SH NAME 4 | ifup - bring a network interface up 5 | 6 | ifdown - take a network interface down 7 | .SH SYNOPSIS 8 | .B ifup CONFIG [boot] 9 | 10 | .B ifdown CONFIG 11 | 12 | .SH DESCRIPTION 13 | The 14 | .B ifup 15 | and 16 | .B ifdown 17 | commands may be used to configure (or, respec- 18 | tively, deconfigure) network interfaces based on interface definitions 19 | in the files /etc/sysconfig/network and /etc/sysconfig/network-scripts/ifcfg- 20 | 21 | These scripts take one argument normally: the name of the configuration 22 | (e.g. eth0). They are called with a second argument of "boot" 23 | during the boot sequence so that devices that are not meant to 24 | be brought up on boot (ONBOOT=no, see below) can be ignored at 25 | that time. 26 | 27 | .SH FILES 28 | .TP 29 | \fB/etc/sysconfig/network\fR 30 | 31 | .TP 32 | \fB/etc/sysconfig/network-scripts/ifcfg-\fR 33 | The file defining an interface. 34 | 35 | .SH "SEE ALSO" 36 | /usr/share/doc/initscripts-*/sysconfig.txt 37 | -------------------------------------------------------------------------------- /man/service.8: -------------------------------------------------------------------------------- 1 | .\" A man page for service(8). -*- nroff -*- 2 | .\" 3 | .\" Copyright (C) 2006 Red Hat, Inc. All rights reserved. 4 | .\" 5 | .\" This copyrighted material is made available to anyone wishing to use, 6 | .\" modify, copy, or redistribute it subject to the terms and conditions of the 7 | .\" GNU General Public License v.2. 8 | .\" 9 | .\" This program is distributed in the hope that it will be useful, but WITHOUT 10 | .\" ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 | .\" FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 | .\" more details. 13 | .\" 14 | .\" You should have received a copy of the GNU General Public License along 15 | .\" with this program; if not, write to the Free Software Foundation, Inc., 16 | .\" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | .\" 18 | .\" Author: Miloslav Trmac 19 | .TH service 8 "Jan 2006" 20 | 21 | .SH NAME 22 | service \- run a System V init script 23 | 24 | .SH SYNOPSIS 25 | \fBservice\fR \fISCRIPT\fR \fICOMMAND\fR [\fIOPTIONS\fR] 26 | 27 | \fBservice \-\-status\-all\fR 28 | 29 | \fBservice\fR \fB\-\-help\fR | \fB\-h\fR | \fB\-\-version\fR 30 | 31 | .SH DESCRIPTION 32 | .B service 33 | runs a System V init script in as predictable environment as possible, 34 | removing most environment variables 35 | and with current working directory set to \fB/\fR. 36 | 37 | The 38 | .I SCRIPT 39 | parameter specifies a System V init script, 40 | located in \fB/etc/init.d/\fISCRIPT\fR. 41 | The supported values of 42 | .I COMMAND 43 | depend on the invoked script, 44 | .B service 45 | passes 46 | .I COMMAND 47 | and 48 | .I OPTIONS 49 | it to the init script unmodified. 50 | All scripts should support at least the 51 | .B start 52 | and 53 | .B stop 54 | commands. 55 | As a special case, if 56 | .I COMMAND 57 | is \fB\-\-full-restart\fR, the script is run twice, first with the 58 | .B stop 59 | command, then with the 60 | .B start 61 | command. 62 | 63 | .B service \-\-status\-all 64 | runs all init scripts, in alphabetical order, with the 65 | .B status 66 | command. 67 | 68 | If the init script file does not exist, the script tries to use 69 | .B legacy actions. 70 | If there is no suitable legacy action found and 71 | .I COMMAND 72 | is one of actions specified in LSB Core Specification, input is redirected to the 73 | .B systemctl. 74 | Otherwise the command fails with return code 2. 75 | 76 | .SH FILES 77 | .TP 78 | \fB/etc/init.d\fR 79 | The directory containing System V init scripts. 80 | 81 | .SH ENVIRONMENT 82 | .TP 83 | \fBPATH\fR, \fBTERM\fR 84 | The only environment variables passed to the init scripts. 85 | 86 | .SH SEE ALSO 87 | .BR chkconfig (8), 88 | .BR ntsysv(8), 89 | .BR systemd (1), 90 | .BR systemctl (8), 91 | .BR systemd.service (5) 92 | -------------------------------------------------------------------------------- /man/usernetctl.8: -------------------------------------------------------------------------------- 1 | .TH USERNETCTL 8 "Red Hat, Inc." "RHS" \" -*- nroff -*- 2 | .SH NAME 3 | usernetctl \- allow a user to manipulate a network interface if permitted 4 | .SH SYNOPSIS 5 | .B usernetctl 6 | \fIinterface-name\fP up\fI|\fPdown\fI|\fPreport 7 | .SH DESCRIPTION 8 | .B usernetctl 9 | checks to see if users are allowed to manipulate the network interface 10 | specified by \fIinterface-name\fP, and then tries to bring the network 11 | interface up or down, if up or down was specified on the command line, 12 | or returns true or false status (respectively) if the report option was 13 | specified. 14 | 15 | .B usernetctl 16 | is not really meant to be called directly by users, though it currently 17 | works fine that way. It is used as a wrapper by the ifup and ifdown 18 | scripts, so that users can do exactly the same thing as root: 19 | .nf 20 | ifup \fIinterface-name\fP 21 | ifdown \fIinterface-name\fP 22 | .fi 23 | and \fBifup\fP and \fBifdown\fP will call usernetctl automatically to 24 | allow the interface status change. 25 | .SH OPTIONS 26 | .TP 27 | .I "\fIinterface-name" 28 | The name of the network interface to check; for example, "ppp0". For 29 | backwards compatibility, "ifcfg-ppp0" and 30 | "/etc/sysconfig/network-scripts/ifcfg-ppp0" are also supported. 31 | .TP 32 | up\fI|\fPdown 33 | Attempt to bring the interface up or down. 34 | .TP 35 | report 36 | Report on whether users can bring the interface up or down. 37 | .SH NOTES 38 | Alternate device configurations may inherit the default configuration's 39 | permissions. 40 | -------------------------------------------------------------------------------- /man/usleep.1: -------------------------------------------------------------------------------- 1 | .TH USLEEP 1 "Red Hat, Inc" \" -*- nroff -*- 2 | .SH NAME 3 | usleep \- sleep some number of microseconds 4 | .SH SYNOPSIS 5 | .B usleep 6 | [\fInumber\fP] 7 | .SH DESCRIPTION 8 | .B usleep 9 | sleeps some number of microseconds. The default is 1. 10 | .SH WARNING 11 | .B usleep 12 | has been deprecated, and will be removed in near future. Use sleep(1) instead. 13 | .SH OPTIONS 14 | \fI--usage\fP 15 | Show short usage message. 16 | .TP 17 | \fI--help, -?\fP 18 | Print help information. 19 | .TP 20 | \fI-v, --version\fP 21 | Print version information. 22 | .SH BUGS 23 | Probably not accurate on many machines down to the microsecond. Count 24 | on precision only to -4 or maybe -5. 25 | .SH AUTHOR 26 | Donald Barnes 27 | .br 28 | Erik Troan 29 | .SH SEE ALSO 30 | sleep(1) 31 | -------------------------------------------------------------------------------- /network-scripts/ifcfg-lo: -------------------------------------------------------------------------------- 1 | DEVICE=lo 2 | IPADDR=127.0.0.1 3 | NETMASK=255.0.0.0 4 | NETWORK=127.0.0.0 5 | # If you're having problems with gated making 127.0.0.0/8 a martian, 6 | # you can change this to something else (255.255.255.255, for example) 7 | BROADCAST=127.255.255.255 8 | ONBOOT=yes 9 | NAME=loopback 10 | -------------------------------------------------------------------------------- /network-scripts/ifdown: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | unset WINDOW # defined by screen, conflicts with our usage 4 | 5 | . /etc/init.d/functions 6 | 7 | cd /etc/sysconfig/network-scripts 8 | . ./network-functions 9 | 10 | [ -f ../network ] && . ../network 11 | 12 | CONFIG=$1 13 | 14 | [ -z "$CONFIG" ] && { 15 | echo $"usage: ifdown " >&2 16 | exit 1 17 | } 18 | 19 | need_config "${CONFIG}" 20 | 21 | [ -f "$CONFIG" ] || { 22 | echo $"usage: ifdown " >&2 23 | exit 1 24 | } 25 | 26 | if [ $UID != 0 ]; then 27 | if [ -x /usr/sbin/usernetctl ]; then 28 | source_config 29 | if /usr/sbin/usernetctl ${CONFIG} report ; then 30 | exec /usr/sbin/usernetctl ${CONFIG} down 31 | fi 32 | fi 33 | echo $"Users cannot control this device." >&2 34 | exit 1 35 | fi 36 | 37 | source_config 38 | 39 | if ! is_true ${DEPRECATION_WARNING_ISSUED}; then 40 | net_log $"You are using 'ifdown' script provided by 'network-scripts', which are now deprecated." warning ifdown >&2 41 | net_log $"'network-scripts' will be removed from distribution in near future." warning ifdown >&2 42 | net_log $"It is advised to switch to 'NetworkManager' instead - it provides 'ifup/ifdown' scripts as well." warning ifdown >&2 43 | fi 44 | 45 | if [ -n "$IN_HOTPLUG" ] && [ "${HOTPLUG}" = "no" -o "${HOTPLUG}" = "NO" ] 46 | then 47 | exit 0 48 | fi 49 | 50 | if is_true "$_use_nm"; then 51 | if [ -n "$UUID" -a -z "$DEVICE" ]; then 52 | DEVICE=$(nmcli -t --fields uuid,device con show --active | awk -F ':' "\$1 == \"$UUID\" { print \$2 }") 53 | fi 54 | if [ -n "$DEVICE" ] && ! is_nm_device_unmanaged "$DEVICE" ; then 55 | if ! LC_ALL=C nmcli -t -f STATE,DEVICE dev status | grep -Eq "^(failed|disconnected|unmanaged|unavailable):$DEVICE$"; then 56 | nmcli dev disconnect "$DEVICE" 57 | exit $? 58 | fi 59 | exit 0 60 | fi 61 | fi 62 | 63 | if [ -x /sbin/ifdown-pre-local ]; then 64 | /sbin/ifdown-pre-local ${DEVICE} 65 | fi 66 | 67 | OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${DEVICETYPE}" 68 | 69 | if [ ! -x ${OTHERSCRIPT} ]; then 70 | OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-${TYPE}" 71 | fi 72 | 73 | if [ ! -x ${OTHERSCRIPT} ]; then 74 | OTHERSCRIPT="/etc/sysconfig/network-scripts/ifdown-eth" 75 | fi 76 | 77 | exec ${OTHERSCRIPT} ${CONFIG} $2 78 | -------------------------------------------------------------------------------- /network-scripts/ifdown-bnep: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | . /etc/init.d/functions 4 | 5 | cd /etc/sysconfig/network-scripts 6 | . ./network-functions 7 | 8 | [ -f ../network ] && . ../network 9 | 10 | CONFIG=${1} 11 | 12 | source_config 13 | 14 | # On hotplug events, just bring the virtual device up as if it's normal Ethernet 15 | if [ -n "$IN_HOTPLUG" ]; then 16 | exec /etc/sysconfig/network-scripts/ifdown-eth ${CONFIG} $2 17 | fi 18 | 19 | stop_panu() 20 | { 21 | kill -TERM $(cat /run/pand-${DEVICE}.pid) 22 | } 23 | 24 | stop_nap() 25 | { 26 | kill -TERM $(cat /run/pand-${DEVICE}.pid) 27 | /usr/bin/pand -K 28 | } 29 | 30 | stop_gn() 31 | { 32 | : 33 | } 34 | 35 | case "$ROLE" in 36 | PANU) 37 | stop_panu 38 | ;; 39 | NAP) 40 | stop_nap 41 | ;; 42 | GN) 43 | stop_gn 44 | ;; 45 | *) 46 | echo Unknown BNEP mode :$ROLE 47 | ;; 48 | esac 49 | 50 | -------------------------------------------------------------------------------- /network-scripts/ifdown-eth: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Network Interface Configuration System 3 | # Copyright (c) 1996-2009 Red Hat, Inc. all rights reserved. 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License, version 2, 7 | # as published by the Free Software Foundation. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, write to the Free Software 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | 18 | . /etc/init.d/functions 19 | 20 | cd /etc/sysconfig/network-scripts 21 | . ./network-functions 22 | 23 | [ -f ../network ] && . ../network 24 | 25 | CONFIG=${1} 26 | 27 | source_config 28 | 29 | . /etc/sysconfig/network 30 | 31 | # Check to make sure the device is actually up 32 | check_device_down ${DEVICE} && [ "$BOOTPROTO" != "dhcp" -a "$BOOTPROTO" != "bootp" ] && [ -n "$VLAN" ] && ! is_true "$VLAN" && exit 0 33 | 34 | if [ -n "${TEAM_MASTER}" ] && [ ! "${DEVICETYPE}" = "TeamPort" ] && [ -x ./ifdown-TeamPort ]; then 35 | ./ifdown-TeamPort ${CONFIG} $2 36 | fi 37 | 38 | if ! is_true "${SLAVE}" || [ -z "${MASTER}" ]; then 39 | if [ -n "${HWADDR}" -a -z "${MACADDR}" ]; then 40 | FOUNDMACADDR=$(get_hwaddr ${REALDEVICE}) 41 | if [ -n "${FOUNDMACADDR}" -a "${FOUNDMACADDR}" != "${HWADDR}" ]; then 42 | NEWCONFIG=$(get_config_by_hwaddr ${FOUNDMACADDR}) 43 | if [ -n "${NEWCONFIG}" ]; then 44 | eval $(LANG=C grep -F "DEVICE=" $NEWCONFIG) 45 | else 46 | net_log $"Device ${DEVICE} has MAC address ${FOUNDMACADDR}, instead of configured address ${HWADDR}. Ignoring." 47 | exit 1 48 | fi 49 | if [ -n "${NEWCONFIG}" -a "${NEWCONFIG##*/}" != "${CONFIG##*/}" -a "${DEVICE}" = "${REALDEVICE}" ]; then 50 | exec /sbin/ifdown ${NEWCONFIG} 51 | else 52 | net_log $"Device ${DEVICE} has MAC address ${FOUNDMACADDR}, instead of configured address ${HWADDR}. Ignoring." 53 | exit 1 54 | fi 55 | fi 56 | fi 57 | fi 58 | 59 | if is_bonding_device ${DEVICE} ; then 60 | for device in $(LANG=C grep -l "^[[:space:]]*MASTER=['\"]\?${DEVICE}['\"]\?\([[:space:]#]\|$\)" /etc/sysconfig/network-scripts/ifcfg-*) ; do 61 | is_ignored_file "$device" && continue 62 | /sbin/ifdown ${device##*/} 63 | done 64 | for arg in $BONDING_OPTS ; do 65 | key=${arg%%=*}; 66 | [[ "${key}" != "arp_ip_target" ]] && continue 67 | value=${arg##*=}; 68 | if [ "${value:0:1}" != "" ]; then 69 | OLDIFS=$IFS; 70 | IFS=','; 71 | for arp_ip in $value; do 72 | if grep -q $arp_ip /sys/class/net/${DEVICE}/bonding/arp_ip_target; then 73 | echo "-$arp_ip" > /sys/class/net/${DEVICE}/bonding/arp_ip_target 74 | fi 75 | done 76 | IFS=$OLDIFS; 77 | else 78 | value=${value#+}; 79 | if grep -q $value /sys/class/net/${DEVICE}/bonding/arp_ip_target; then 80 | echo "-$value" > /sys/class/net/${DEVICE}/bonding/arp_ip_target 81 | fi 82 | fi 83 | done 84 | fi 85 | 86 | /etc/sysconfig/network-scripts/ifdown-ipv6 ${CONFIG} 87 | 88 | retcode=0 89 | 90 | for VER in "" 6 ; do 91 | if [ -f "/run/dhclient$VER-${DEVICE}.pid" ]; then 92 | dhcpid=$(cat /run/dhclient$VER-${DEVICE}.pid) 93 | generate_lease_file_name $VER 94 | if is_true "$DHCPRELEASE"; then 95 | /sbin/dhclient -r -lf ${LEASEFILE} -pf /run/dhclient$VER-${DEVICE}.pid ${DEVICE} >/dev/null 2>&1 96 | retcode=$? 97 | else 98 | kill $dhcpid >/dev/null 2>&1 99 | retcode=$? 100 | reason=STOP$VER interface=${DEVICE} /sbin/dhclient-script 101 | fi 102 | if [ -f "/run/dhclient$VER-${DEVICE}.pid" ]; then 103 | rm -f /run/dhclient$VER-${DEVICE}.pid 104 | kill $dhcpid >/dev/null 2>&1 105 | fi 106 | fi 107 | done 108 | 109 | # we can't just delete the configured address because that address 110 | # may have been changed in the config file since the device was 111 | # brought up. Flush all addresses associated with this 112 | # instance instead. 113 | if [ -d "/sys/class/net/${REALDEVICE}" ]; then 114 | LABEL= 115 | if [ "${REALDEVICE}" != "${DEVICE}" ]; then 116 | LABEL="label ${DEVICE}" 117 | fi 118 | if [ "${REALDEVICE}" = "lo" ]; then 119 | TIMEOUT="" 120 | [ -x /usr/bin/timeout ] && TIMEOUT="/usr/bin/timeout --signal=SIGQUIT 4" 121 | $TIMEOUT ip addr flush dev ${REALDEVICE} ${LABEL} scope global 2>/dev/null 122 | $TIMEOUT ip addr flush dev ${REALDEVICE} ${LABEL} scope host 2>/dev/null 123 | else 124 | ip addr flush dev ${REALDEVICE} ${LABEL} scope global 2>/dev/null 125 | ip -4 addr flush dev ${REALDEVICE} ${LABEL} scope host 2>/dev/null 126 | fi 127 | 128 | if is_true "${SLAVE}" && [ -n "${MASTER}" ]; then 129 | echo "-${DEVICE}" > /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null 130 | fi 131 | 132 | if [ "${REALDEVICE}" = "${DEVICE}" ]; then 133 | ip link set dev ${DEVICE} down 2>/dev/null 134 | fi 135 | fi 136 | [ "$retcode" = "0" ] && retcode=$? 137 | 138 | if [ -n "${BRIDGE}" ]; then 139 | ip link set dev ${DEVICE} nomaster down 140 | # Upon removing a device from a bridge, 141 | # it's necessary to make radvd reload its config 142 | [ -r /run/radvd/radvd.pid ] && kill -HUP $(cat /run/radvd/radvd.pid) 143 | if [ -d /sys/class/net/${BRIDGE}/brif ] && [ $(ls -1 /sys/class/net/${BRIDGE}/brif | wc -l) -eq 0 ]; then 144 | ip link del ${BRIDGE} 145 | fi 146 | fi 147 | 148 | if [ "${TYPE}" = "Tap" ]; then 149 | TUNMODE="mode tap" 150 | [[ ${DEVICE} == tun* ]] && TUNMODE="mode tun" 151 | ip tuntap del ${TUNMODE} dev ${DEVICE} >/dev/null 152 | fi 153 | 154 | if [ -n "${TEAM_CONFIG}" ] && [ ! "${DEVICETYPE}" = "Team" ] && [ -x ./ifdown-Team ]; then 155 | ./ifdown-Team ${CONFIG} $2 156 | fi 157 | 158 | # wait up to 5 seconds for device to actually come down... 159 | waited=0 160 | while ! check_device_down ${DEVICE} && [ "$waited" -lt 50 ] ; do 161 | sleep 0.01 162 | waited=$(($waited+1)) 163 | done 164 | 165 | # don't leave an outdated key sitting around 166 | if [ -n "${WIRELESS_ENC_KEY}" ] && [ -x /sbin/iwconfig ]; then 167 | /sbin/iwconfig ${DEVICE} enc 0 >/dev/null 2>&1 168 | fi 169 | 170 | if [ "$retcode" = "0" ]; then 171 | /etc/sysconfig/network-scripts/ifdown-post $CONFIG 172 | # do NOT use $? because ifdown should return whether or not 173 | # the interface went down. 174 | fi 175 | 176 | if [ -n "$VLAN" ]; then 177 | # 802.1q VLAN 178 | if [ -f /proc/net/vlan/${DEVICE} ]; then 179 | ip link delete ${DEVICE} type vlan 180 | fi 181 | fi 182 | 183 | if [ "${TYPE}" = "Veth" ]; then 184 | if [ $(ip link show ${PEER} up | wc -l) -eq 0 ]; then 185 | ip link delete ${DEVICE} 186 | fi 187 | fi 188 | 189 | exit $retcode 190 | -------------------------------------------------------------------------------- /network-scripts/ifdown-ippp: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | PATH=/sbin:/usr/sbin:/bin:/usr/bin 4 | 5 | # Get global network configuration 6 | [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network 7 | 8 | CONFIG=$1 9 | 10 | . ./$CONFIG 11 | 12 | # stopping ibod daemon for channel bundling 13 | if [ -f /var/lock/subsys/ibod ] ; then 14 | kill -9 $(pidof ibod) >/dev/null 2>&1 15 | rm -f /var/lock/subsys/ibod 16 | fi 17 | 18 | # Shut down IPv6 19 | /etc/sysconfig/network-scripts/ifdown-ipv6 $CONFIG 20 | 21 | # shutdown isdn device 22 | isdnctrl hangup $DEVICE >/dev/null 2>&1 23 | sleep 1 24 | ip link set dev $DEVICE down >/dev/null 2>&1 25 | 26 | # delete isdn device 27 | isdnctrl delif $DEVICE >/dev/null 2>&1 28 | 29 | # kill ipppd daemon 30 | if [ -f /run/ipppd.$DEVICE.pid ] ; then 31 | pppdpid=$(cat /run/ipppd.$DEVICE.pid) 32 | kill -9 $pppdpid > /dev/null 2>&1 33 | rm -f /run/ipppd.$DEVICE.pid > /dev/null 2>&1 34 | fi 35 | -------------------------------------------------------------------------------- /network-scripts/ifdown-ipv6: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # ifdown-ipv6 4 | # 5 | # 6 | # Taken from: 7 | # (P) & (C) 2000-2004 by Peter Bieringer 8 | # 9 | # You will find more information on the initscripts-ipv6 homepage at 10 | # http://www.deepspace6.net/projects/initscripts-ipv6.html 11 | # 12 | # RHL integration assistance by Pekka Savola 13 | # 14 | # Version 2005-09-22 15 | # 16 | # Note: if called as (like normally) by /etc/sysconfig/network-scripts/ifdown 17 | # exit codes aren't handled by "ifdown" 18 | # 19 | # Uses following information from /etc/sysconfig/network-scripts/ifcfg-$1: 20 | # DEVICE= 21 | # IPV6INIT=yes|no: controls IPv6 configuration for this interface 22 | # 23 | # Optional for 6to4 tunneling: 24 | # IPV6TO4_RELAY=: IPv4 address of the remote 6to4 relay [default: 192.88.99.1] 25 | # IPV6TO4_ROUTING="-/ ...": information to setup internal interfaces 26 | # 27 | # Optional for 6to4 tunneling links to trigger radvd: 28 | # IPV6_CONTROL_RADVD=yes|no: controls radvd triggering [optional] 29 | # IPV6_RADVD_PIDFILE=: PID file of radvd for sending signals, default is "/run/radvd/radvd.pid" [optional] 30 | # IPV6_RADVD_TRIGGER_ACTION=startstop|reload|restart|SIGHUP: how to trigger radvd [optional, default is SIGHUP] 31 | # 32 | # Required version of radvd to use 6to4 prefix recalculation 33 | # 0.6.2p3 or newer supporting option "Base6to4Interface" 34 | # Required version of radvd to use dynamic ppp links 35 | # 0.7.0 + fixes or newer 36 | # 37 | 38 | 39 | . /etc/sysconfig/network 40 | 41 | cd /etc/sysconfig/network-scripts 42 | . ./network-functions 43 | 44 | CONFIG=$1 45 | [ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG 46 | source_config 47 | 48 | REALDEVICE=${DEVICE%%:*} 49 | DEVICE=$REALDEVICE 50 | 51 | [ -f /etc/sysconfig/network-scripts/network-functions-ipv6 ] || exit 1 52 | . /etc/sysconfig/network-scripts/network-functions-ipv6 53 | 54 | 55 | # IPv6 test, no module loaded, exit if system is not IPv6-ready 56 | ipv6_test testonly || exit 0 57 | 58 | # Test device status 59 | ipv6_test_device_status $DEVICE 60 | if [ $? != 0 -a $? != 11 ]; then 61 | # device doesn't exist or other problem occurs 62 | exit 1 63 | fi 64 | 65 | if ! is_false "$IPV6_SET_SYSCTLS"; then 66 | # Switch some sysctls to secure mode 67 | /sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.forwarding=0 >/dev/null 2>&1 68 | /sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.accept_ra=0 >/dev/null 2>&1 69 | /sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.accept_redirects=0 >/dev/null 2>&1 70 | fi 71 | /sbin/ip link set $DEVICE addrgenmode eui64 >/dev/null 2>&1 72 | 73 | # Test status of tun6to4 device 74 | ipv6_test_device_status tun6to4 75 | if [ $? = 0 -o $? = 11 ]; then 76 | # Device exists 77 | valid6to4config="yes" 78 | 79 | if [ -z "$IPV6TO4_RELAY" ]; then 80 | IPV6TO4_RELAY="192.88.99.1" 81 | fi 82 | 83 | # Get IPv4 address from interface 84 | if [ -n "$IPV6TO4_IPV4ADDR" ]; then 85 | # Take special configured from config file (precedence 1) 86 | ipv4addr="$IPV6TO4_IPV4ADDR" 87 | 88 | # Get IPv4 address from interface first 89 | ipv4addrlocal="$(ipv6_get_ipv4addr_of_device $DEVICE)" 90 | if [ -z "$ipv4addrlocal" ]; then 91 | # Take configured from config file 92 | ipv4addrlocal="$IPADDR" 93 | fi 94 | else 95 | # Get IPv4 address from interface first (has precedence 2) 96 | ipv4addr="$(ipv6_get_ipv4addr_of_device $DEVICE)" 97 | if [ -z "$ipv4addr" ]; then 98 | # Take configured from config file (precedence 3) 99 | ipv4addr="$IPADDR" 100 | fi 101 | ipv4addrlocal="$ipv4addr" 102 | fi 103 | 104 | # Get local IPv4 address of dedicated tunnel 105 | ipv4addr6to4local="$(ipv6_get_ipv4addr_of_tunnel tun6to4 local)" 106 | 107 | if [ -z "$ipv4addrlocal" -o -z "$ipv4addr6to4local" ]; then 108 | # no IPv4 addresses given, 6to4 sure not configured 109 | valid6to4config="no" 110 | else 111 | # Check against configured 6to4 tunnel to see if this interface was 112 | # used before 113 | if [ "$ipv4addrlocal" != "$ipv4addr6to4local" ]; then 114 | # IPv4 address of interface does't match local tunnel address, 115 | # interface was not used for current 6to4 setup 116 | valid6to4config="no" 117 | fi 118 | fi 119 | fi 120 | 121 | # Shutdown of 6to4, if configured 122 | if is_true "$valid6to4config"; then 123 | if [ -n "$IPV6TO4_ROUTING" ]; then 124 | # Delete routes to local networks 125 | for devsuf in $IPV6TO4_ROUTING; do 126 | dev="${devsuf%%-*}" 127 | ipv6_cleanup_6to4_device $dev 128 | done 129 | fi 130 | 131 | # Delete all configured 6to4 address 132 | ipv6_cleanup_6to4_tunnels tun6to4 133 | 134 | # Control running radvd 135 | ipv6_trigger_radvd down "$IPV6_RADVD_TRIGGER_ACTION" $IPV6_RADVD_PIDFILE 136 | fi 137 | 138 | # Delete all current configured IPv6 addresses on this interface 139 | ipv6_cleanup_device $DEVICE 140 | -------------------------------------------------------------------------------- /network-scripts/ifdown-post: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # This should be called whenever an interface goes down, not just when 3 | # it is brought down explicitly. 4 | 5 | cd /etc/sysconfig/network-scripts 6 | . ./network-functions 7 | 8 | unset REALDEVICE 9 | if [ "$1" = --realdevice ] ; then 10 | REALDEVICE=$2 11 | shift 2 12 | fi 13 | 14 | CONFIG=$1 15 | source_config 16 | 17 | [ -z "$REALDEVICE" ] && REALDEVICE=$DEVICE 18 | 19 | /etc/sysconfig/network-scripts/ifdown-routes ${REALDEVICE} ${DEVNAME} 20 | 21 | # Remove duplicate DNS entries and shift them, 22 | # to have always correct condition below... 23 | update_DNS_entries 24 | 25 | if ! is_false "${PEERDNS}" || is_true "${RESOLV_MODS}" && \ 26 | [ "${DEVICETYPE}" = "ppp" -o "${DEVICETYPE}" = "ippp" -o -n "${DNS1}" \ 27 | -o "${BOOTPROTO}" = "bootp" -o "${BOOTPROTO}" = "dhcp" ] ; then 28 | if [ -f /etc/resolv.conf.save ]; then 29 | change_resolv_conf /etc/resolv.conf.save 30 | rm -f /etc/resolv.conf.save 31 | fi 32 | if [ "${DEVICETYPE}" = "ppp" -o "${DEVICETYPE}" = "ippp" ]; then 33 | if [ -f /etc/ppp/peers/$DEVICE ] ; then 34 | rm -f /etc/ppp/peers/$DEVICE 35 | fi 36 | fi 37 | fi 38 | 39 | # Reset the default route if this interface had a special one 40 | if ! check_default_route ; then 41 | # ISDN device needs special handling dial on demand 42 | if [ "${DEVICETYPE}" = "ippp" -o "${DEVICETYPE}" = "isdn" ] && \ 43 | [ "$DIALMODE" = "auto" ] ; then 44 | if [ -z "$GATEWAY" ] ; then 45 | /sbin/ip route add default ${METRIC:+metric} \ 46 | ${WINDOW:+window $WINDOW} dev ${DEVICE} 47 | else 48 | /sbin/ip route add default ${METRIC:+metric} \ 49 | ${WINDOW:+window $WINDOW} via ${GATEWAY} 50 | fi 51 | else 52 | add_default_route ${DEVICE} 53 | fi 54 | fi 55 | 56 | # Reset firewall zone (empty ZONE means default): 57 | if [ "${REALDEVICE}" != "lo" ]; then 58 | dbus-send --print-reply --system --dest=org.fedoraproject.FirewallD1 \ 59 | /org/fedoraproject/FirewallD1 \ 60 | org.fedoraproject.FirewallD1.zone.removeInterface \ 61 | string:"" string:"${DEVICE}" \ 62 | > /dev/null 2>&1 63 | fi 64 | 65 | if [ -x /sbin/ifdown-local ]; then 66 | /sbin/ifdown-local ${DEVICE} 67 | fi 68 | 69 | exit 0 70 | -------------------------------------------------------------------------------- /network-scripts/ifdown-routes: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # Drops static routes which go through device $1 4 | 5 | if [ -z "$1" ]; then 6 | echo $"usage: ifdown-routes []" 7 | exit 1 8 | fi 9 | 10 | # The routes are actually dropped just by setting the link down, so nothing 11 | # needs to be done 12 | 13 | MATCH='^[[:space:]]*(\#.*)?$' 14 | 15 | # Routing rules 16 | FILES="/etc/sysconfig/network-scripts/rule-$1 /etc/sysconfig/network-scripts/rule6-$1" 17 | if [ -n "$2" -a "$2" != "$1" ]; then 18 | FILES="$FILES /etc/sysconfig/network-scripts/rule-$2 /etc/sysconfig/network-scripts/rule6-$2" 19 | fi 20 | 21 | for file in $FILES; do 22 | if [ -f "$file" ]; then 23 | proto= 24 | if [ "$file" != "${file##*/rule6-}" ]; then 25 | proto="-6" 26 | fi 27 | { cat "$file" ; echo ; } | while read line; do 28 | if [[ ! "$line" =~ $MATCH ]]; then 29 | /sbin/ip $proto rule del $line 30 | fi 31 | done 32 | fi 33 | done 34 | -------------------------------------------------------------------------------- /network-scripts/ifdown-sit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # ifdown-sit 4 | # 5 | # 6 | # Taken from: 7 | # (P) & (C) 2000-2003 by Peter Bieringer 8 | # 9 | # You will find more information on the initscripts-ipv6 homepage at 10 | # http://www.deepspace6.net/projects/initscripts-ipv6.html 11 | # 12 | # RHL integration assistance by Pekka Savola 13 | # 14 | # Version 2002-11-01 15 | # 16 | # Uses following information from /etc/sysconfig/network-scripts/ifcfg-$1: 17 | # DEVICE= 18 | # 19 | 20 | 21 | . /etc/sysconfig/network 22 | 23 | cd /etc/sysconfig/network-scripts 24 | . ./network-functions 25 | 26 | CONFIG=$1 27 | [ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG 28 | source_config 29 | 30 | # IPv6 don't need aliases anymore, config is skipped 31 | REALDEVICE=${DEVICE%%:*} 32 | [ "$DEVICE" != "$REALDEVICE" ] && exit 0 33 | 34 | [ -f /etc/sysconfig/network-scripts/network-functions-ipv6 ] || exit 1 35 | . /etc/sysconfig/network-scripts/network-functions-ipv6 36 | 37 | 38 | # Generic tunnel device sit0 is not supported here 39 | if [ "$DEVICE" = "sit0" ]; then 40 | net_log $"Device '$DEVICE' isn't supported here, use IPV6_AUTOTUNNEL setting and restart (IPv6) networking" 41 | exit 1 42 | fi 43 | 44 | # IPv6 test, no module loaded, exit if system is not IPv6-ready 45 | ipv6_test testonly || exit 0 46 | 47 | # Test device status 48 | ipv6_test_device_status $DEVICE 49 | if [ $? != 0 -a $? != 11 ]; then 50 | # device doesn't exist or other problem occurs 51 | exit 0 52 | fi 53 | 54 | # Cleanup additional static routes 55 | /etc/sysconfig/network-scripts/ifdown-routes ${REALDEVICE} 56 | 57 | # Cleanup and shut down IPv6-in-IPv4 tunnel device 58 | ipv6_del_tunnel_device $DEVICE 59 | -------------------------------------------------------------------------------- /network-scripts/ifdown-tunnel: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (C) 1996-2006 Red Hat, Inc. all rights reserved. 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License, version 2, 6 | # as published by the Free Software Foundation. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | 17 | # Thanks to: 18 | # - Razvan Corneliu C.R. Vilt 19 | # - Aaron Hope 20 | # - Sean Millichamp 21 | # for providing the scripts this one is based on 22 | 23 | . /etc/init.d/functions 24 | 25 | cd /etc/sysconfig/network-scripts 26 | . ./network-functions 27 | 28 | [ -f ../network ] && . ../network 29 | 30 | CONFIG=$1 31 | need_config "$CONFIG" 32 | source_config 33 | 34 | # Generic tunnel devices are not supported here 35 | if [ "$DEVICE" = gre0 -o "$DEVICE" = tunl0 -o "$DEVICE" = ip6tnl0 ]; then 36 | net_log $"Device '$DEVICE' isn't supported as a valid GRE device name." 37 | exit 1 38 | fi 39 | 40 | check_device_down "$DEVICE" && exit 0 41 | 42 | /sbin/ip link set dev "$DEVICE" down 43 | /sbin/ip tunnel del "$DEVICE" 44 | 45 | exec /etc/sysconfig/network-scripts/ifdown-post "$CONFIG" 46 | -------------------------------------------------------------------------------- /network-scripts/ifup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Network Interface Configuration System 3 | # Copyright (c) 1996-2009 Red Hat, Inc. all rights reserved. 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License, version 2, 7 | # as published by the Free Software Foundation. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, write to the Free Software 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | 18 | unset WINDOW # defined by screen, conflicts with our usage 19 | 20 | . /etc/init.d/functions 21 | 22 | cd /etc/sysconfig/network-scripts 23 | . ./network-functions 24 | 25 | [ -f ../network ] && . ../network 26 | 27 | CONFIG=${1} 28 | 29 | [ -z "${CONFIG}" ] && { 30 | echo $"Usage: ifup " >&2 31 | exit 1 32 | } 33 | 34 | need_config "${CONFIG}" 35 | 36 | [ -f "${CONFIG}" ] || { 37 | echo $"$0: configuration for ${1} not found." >&2 38 | echo $"Usage: ifup " >&2 39 | exit 1 40 | } 41 | 42 | if [ ${UID} != 0 ]; then 43 | if [ -x /usr/sbin/usernetctl ]; then 44 | source_config 45 | if /usr/sbin/usernetctl ${CONFIG} report ; then 46 | exec /usr/sbin/usernetctl ${CONFIG} up 47 | fi 48 | fi 49 | echo $"Users cannot control this device." >&2 50 | exit 1 51 | fi 52 | 53 | source_config 54 | 55 | if ! is_true ${DEPRECATION_WARNING_ISSUED}; then 56 | net_log $"You are using 'ifup' script provided by 'network-scripts', which are now deprecated." warning ifup >&2 57 | net_log $"'network-scripts' will be removed from distribution in near future." warning ifup >&2 58 | net_log $"It is advised to switch to 'NetworkManager' instead - it provides 'ifup/ifdown' scripts as well." warning ifup >&2 59 | fi 60 | 61 | if [ "foo$2" = "fooboot" ] && is_false "${ONBOOT}" 62 | then 63 | exit 0 64 | fi 65 | if [ -n "$IN_HOTPLUG" ] && is_false "${HOTPLUG}" 66 | then 67 | exit 0 68 | fi 69 | if [ -n "$IN_HOTPLUG" -a "${TYPE}" = "Bridge" ]; 70 | then 71 | exit 0 72 | fi 73 | 74 | if is_true "$_use_nm" && [ -n "$UUID" ] && [ "$REALDEVICE" != "lo" ]; then 75 | if [ "foo$2" = "fooboot" ] && [ "${TYPE}" = "Wireless" ]; then 76 | exit 0 77 | fi 78 | [ -n "${DEVICE}" ] && is_nm_handling ${DEVICE} && exit 0 79 | nmcli con up uuid "$UUID" 80 | exit $? 81 | fi 82 | 83 | # Ethernet 802.1Q VLAN support 84 | if is_true "${VLAN}" && is_false "$ISALIAS" && [ -n "$DEVICE" ]; then 85 | if [ -n "${VID}" ]; then 86 | if test -z "$PHYSDEV"; then 87 | net_log $"PHYSDEV should be set for device ${DEVICE}" 88 | exit 1 89 | fi 90 | else 91 | VID="" 92 | MATCH='^.+\.[0-9]{1,4}$' 93 | if [[ "${DEVICE}" =~ $MATCH ]]; then 94 | VID=$(echo "${DEVICE}" | LC_ALL=C sed 's/^.*\.\([0-9]\+\)/\1/') 95 | PHYSDEV=${DEVICE%.*} 96 | fi 97 | MATCH='^vlan[0-9]{1,4}?' 98 | if [[ "${DEVICE}" =~ $MATCH ]]; then 99 | VID=$(echo "${DEVICE}" | LC_ALL=C sed 's/^vlan0*//') 100 | # PHYSDEV should be set in ifcfg-vlan* file 101 | if test -z "$PHYSDEV"; then 102 | net_log $"PHYSDEV should be set for device ${DEVICE}" 103 | exit 1 104 | fi 105 | fi 106 | fi 107 | if [ -n "$VID" ]; then 108 | if [ ! -d /proc/net/vlan ]; then 109 | if ! modprobe 8021q >/dev/null 2>&1 ; then 110 | net_log $"No 802.1Q VLAN support available in kernel for device ${DEVICE}" 111 | exit 1 112 | fi 113 | fi 114 | 115 | is_available_wait ${PHYSDEV} ${DEVTIMEOUT} || { 116 | if [ "$?" = "1" ] ; then 117 | net_log $"$alias device ${DEVICE} does not seem to be present, delaying initialization." 118 | exit 1 119 | else 120 | exit 0 121 | fi 122 | } 123 | 124 | # Link on Physical device needs to be up but no ip required 125 | check_device_down ${PHYSDEV} && set_link_up ${PHYSDEV} 126 | 127 | if [ ! -f /proc/net/vlan/${DEVICE} ]; then 128 | if is_false "${REORDER_HDR}"; then 129 | FLAG_REORDER_HDR="reorder_hdr off" 130 | fi 131 | 132 | if is_true "${GVRP}"; then 133 | FLAG_GVRP="gvrp on" 134 | fi 135 | 136 | ip link add dev ${DEVICE} link ${PHYSDEV} type vlan id ${VID} ${FLAG_REORDER_HDR} ${FLAG_GVRP} || { 137 | net_log $"ERROR: could not add vlan ${VID} as ${DEVICE} on dev ${PHYSDEV}" info ifup 138 | exit 1 139 | } 140 | 141 | [ -n "${VLAN_EGRESS_PRIORITY_MAP}" ] && ip link set dev ${DEVICE} type vlan egress ${VLAN_EGRESS_PRIORITY_MAP} 142 | fi 143 | fi 144 | 145 | /usr/lib/systemd/systemd-sysctl \ 146 | --prefix "/proc/sys/net/ipv4/conf/${DEVICE}" \ 147 | --prefix "/proc/sys/net/ipv6/conf/${DEVICE}" 148 | fi 149 | 150 | if [ "${BOOTPROTO}" = "bootp" -o "${BOOTPROTO}" = "dhcp" ]; then 151 | DYNCONFIG=true 152 | fi 153 | 154 | if [ -x /sbin/ifup-pre-local ]; then 155 | /sbin/ifup-pre-local ${CONFIG} $2 156 | fi 157 | 158 | OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${DEVICETYPE}" 159 | 160 | if [ ! -x ${OTHERSCRIPT} ]; then 161 | OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-${TYPE}" 162 | fi 163 | 164 | if [ ! -x ${OTHERSCRIPT} ]; then 165 | OTHERSCRIPT="/etc/sysconfig/network-scripts/ifup-eth" 166 | fi 167 | 168 | exec ${OTHERSCRIPT} ${CONFIG} $2 169 | -------------------------------------------------------------------------------- /network-scripts/ifup-aliases: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # configures aliases of device $1 5 | # 6 | # This script goes out of its way to arrive at the configuration of ip 7 | # aliases described in the ifcfg-$DEV:* and ifcfg-$DEV-range* files from 8 | # whatever existing configuration it may be given: existing aliases not 9 | # specified in the configuration will be removed, netmasks and broadcast 10 | # addrs will be updated on existing aliases, and new aliases will be setup. 11 | # 12 | # range specification files: 13 | # 14 | # One can specify ranges of alised ipaddress using ifcfg-$DEV-range* files. 15 | # Specify multiple ranges using multiple files, such as ifcfg-eth0-range0 and 16 | # ifcfg-eth0-range1, etc. In these files, the following configuration variables 17 | # specify the range: 18 | # 19 | # IPADDR_START -- ipaddr to start range at. eg "192.168.30.1" 20 | # IPADDR_END -- ipaddr to end range at. eg "192.168.30.254" 21 | # CLONENUM_START -- interface clone number to start using for this range. eg "0" 22 | # 23 | # The above example values create the interfaces eth0:0 through eth0:253 using 24 | # ipaddrs 192.168.30.1 through 192.168.30.254, inclusive. 25 | # 26 | # Other configuration variables such as NETMASK and BROADCAST may be specified 27 | # in the range file and will apply to all of the ipaddresses in the range. Range 28 | # files also inherit configuration from the ifcfg-$DEV file just like normal. 29 | # 30 | # Note that IPADDR_START and IPADR_END are required to be in the same class-c 31 | # block. I.e. IPADDR_START=192.168.30.1 and IPADDR_END=192.168.31.255 is 32 | # not valid. 33 | # 34 | # speed with large sets of interfaces: 35 | # 36 | # Considerable effort was spent making this script fast. It can efficiently 37 | # handle a thousand ip aliases on one interface. 38 | # 39 | # With large sets of ipaddresses the NO_ALIASROUTING=yes configuration is 40 | # highly recommended. (This can be specified in ifcfg-$DEV and inherited.) This 41 | # prevents this script from setting up routing details for the virtual 42 | # interfaces, which I don't think is needed, because outgoing traffic can use the 43 | # main interface. However, make your own conclusions on what you need. 44 | # 45 | # My test setup of four class C address blocks on a P166 took 25 seconds of 46 | # which 16 seconds of this was spent in the ifcconfig calls. Without the 47 | # NO_ALIASROUTING=yes config an additional 12 seconds is spent in route calls. 48 | # 49 | # notes on internals: 50 | # 51 | # This script uses the bash "eval" command to lookup shell variables with names 52 | # which are generated from other shell variables. This allows us to, in effect, 53 | # create hashes using the shell variable namesspace by just including the hash 54 | # key in the name of the variable. 55 | # 56 | # This script originally written by: David Harris 57 | # Principal Engineer, DRH Internet 58 | # June 30, 1999 59 | # 60 | # modified by: Bill Nottingham 61 | 62 | TEXTDOMAIN=initscripts 63 | TEXTDOMAINDIR=/etc/locale 64 | 65 | device=$1 66 | if [ "$device" = "" ]; then 67 | echo $"usage: ifup-aliases []\n" 68 | exit 1 69 | fi 70 | 71 | PARENTCONFIG=${2:-ifcfg-$device} 72 | parent_device=$device 73 | 74 | cd /etc/sysconfig/network-scripts 75 | . ./network-functions 76 | 77 | # Grab the current configuration of any running aliases, place device info 78 | # into variables of the form: 79 | # rdev__addr = 80 | # rdev__pb = _ 81 | # rdevip_ = 82 | # Example: 83 | # rdev_0_addr=192.168.1.1 84 | # rdev_0_pb=24_192.16.1.255 85 | # rdevip_192_168_1_1=0 86 | # 87 | # A list of all the devices is created in rdev_LIST. 88 | 89 | eval $( ip addr show $device label $device:* | \ 90 | awk 'BEGIN { COUNT=0;LAST_DEV="" } /inet / { 91 | # Split IP address into address/prefix 92 | split($2,IPADDR,"/"); 93 | # Create A_B_C_D IP address form 94 | IP_ADDR=IPADDR[1]; 95 | gsub(/\./,"_",IP_ADDR); 96 | # Split device into device:index 97 | split($NF,DEV,":"); 98 | # Update last device 99 | LAST_DEV=LAST_DEV " " DEV[2]; 100 | printf("rdev_%s_addr=%s\nrdevip_%s=%s\nrdev_%s_pb=%s_%s\nrdev_LIST=\"%s\"\n", 101 | DEV[2],IPADDR[1],IP_ADDR,DEV[2],DEV[2],IPADDR[2],$4,LAST_DEV); 102 | } END { 103 | if(LAST_DEV == "") print "no_devices_are_up=yes" 104 | }' ); 105 | 106 | # 107 | # Store configuration of the parent device and network 108 | # 109 | 110 | # read from the /etc/sysconfig/network 111 | eval ` ( 112 | . /etc/sysconfig/network; 113 | echo network_GATEWAY=$GATEWAY\;; 114 | echo network_GATEWAYDEV=$GATEWAYDEV\;; 115 | ) ` 116 | 117 | # read defaults from the parent config file 118 | [ -f $PARENTCONFIG ] || { 119 | net_log $"Missing config file $PARENTCONFIG." 120 | exit 1 121 | } 122 | eval ` ( 123 | . ./$PARENTCONFIG; 124 | echo default_PREFIX=$PREFIX\;; 125 | echo default_NETMASK=$NETMASK\;; 126 | echo default_BROADCAST=$BROADCAST\;; 127 | echo default_GATEWAY=$GATEWAY\;; 128 | echo default_NO_ALIASROUTING=$NO_ALIASROUTING\;; 129 | echo default_ARPCHECK=$ARPCHECK\;; 130 | echo default_ARPUPDATE=$ARPUPDATE\;; 131 | ) ` 132 | [ -z "$default_GATEWAY" ] && default_GATEWAY=$network_GATEWAY 133 | 134 | function ini_env () 135 | { 136 | DEVICE="" 137 | IPADDR="" 138 | IPV6ADDR="" 139 | PREFIX=$default_PREFIX 140 | NETMASK=$default_NETMASK 141 | BROADCAST=$default_BROADCAST 142 | GATEWAY=$default_GATEWAY 143 | NO_ALIASROUTING=$default_NO_ALIASROUTING 144 | ONPARENT="" 145 | ARPCHECK=$default_ARPCHECK 146 | ARPUPDATE=$default_ARPUPDATE 147 | } 148 | 149 | function is_default_gateway () 150 | { 151 | LC_ALL=C /sbin/ip route ls default scope global \ 152 | | awk '$3 == "'"$1"'" { found = 1; } END { exit found == 0; }' 153 | } 154 | 155 | # 156 | # Read the alias configuration files and enable each aliased 157 | # device using new_interface() 158 | # 159 | 160 | function new_interface () 161 | { 162 | 163 | ipa=$IPADDR; ipb=${ipa#*.}; ipc=${ipb#*.}; 164 | IPGLOP="${ipa%%.*}_${ipb%%.*}_${ipc%%.*}_${ipc#*.}"; 165 | DEVNUM=${DEVICE#*:} 166 | 167 | MATCH='^[0-9A-Za-z_]*$' 168 | if (LC_ALL=C; [[ ! "$DEVNUM" =~ $MATCH ]]); then 169 | net_log $"error in $FILE: invalid alias number" 170 | return 1 171 | fi 172 | 173 | eval " 174 | ipseen=\$ipseen_${IPGLOP}; devseen=\$devseen_${DEVNUM}; 175 | ipseen_${IPGLOP}=$FILE; devseen_${DEVNUM}=$FILE; 176 | "; 177 | 178 | if [ -n "$ipseen" ]; then 179 | net_log $"error in $FILE: already seen ipaddr $IPADDR in $ipseen" 180 | return 1 181 | fi 182 | 183 | if [ -n "$devseen" ]; then 184 | net_log $"error in $FILE: already seen device $parent_device:$DEVNUM in $devseen" 185 | return 1 186 | fi 187 | 188 | if [ -z "$DEVICE" -o -z "$IPADDR" ]; then 189 | if [ -n "$IPV6ADDR" -a -n "$DEVICE" ] && ! is_false "$IPV6INIT"; then 190 | /etc/sysconfig/network-scripts/ifup-ipv6 ${DEVICE} 191 | return $? 192 | fi 193 | net_log $"error in $FILE: didn't specify device or ipaddr" 194 | return 1 195 | fi 196 | 197 | if [ -z "$NETMASK" -a -z "$PREFIX" ]; then 198 | net_log $"error iN $FILE: didn't specify netmask or prefix" 199 | fi 200 | 201 | if [ -z "$PREFIX" ]; then 202 | eval $(/bin/ipcalc --prefix ${IPADDR} ${NETMASK}) 203 | fi 204 | 205 | if [ -z "$BROADCAST" -o "$BROADCAST" = "$default_BROADCAST" ]; then 206 | eval $(/bin/ipcalc --broadcast ${IPADDR}/${PREFIX}) 207 | fi 208 | 209 | if is_true "$no_devices_are_up"; then 210 | setup_this=yes 211 | else 212 | 213 | setup_this="" 214 | 215 | eval " 216 | rdev_addr=\$rdev_${DEVNUM}_addr; 217 | rdev_pb=\$rdev_${DEVNUM}_pb; 218 | rdev_mark=\$rdev_${DEVNUM}_mark; 219 | rdevip=\$rdevip_${IPGLOP}; 220 | "; 221 | 222 | if [ -n "$rdev_addr" ]; then 223 | if [ "$rdev_addr" = "${IPADDR}" ]; then 224 | newmark=keep 225 | if [ "$rdev_pb" != "${PREFIX}_${BROADCAST}" ]; then 226 | setup_this=freshen 227 | else 228 | setup_this=no 229 | fi 230 | else 231 | if [ "$rdev_mark" != "remove" ]; then 232 | /sbin/ip addr flush dev $parent_device label $parent_device:${DEVNUM} 233 | fi 234 | newmark=remove 235 | setup_this=yes 236 | fi 237 | if [ -n "$rdev_mark" -a "$rdev_mark" != "$newmark" ]; then 238 | net_log $"error in ifcfg-${parent_device}: files" 239 | return 1 240 | fi 241 | eval " rdev_${DEVNUM}_mark=\$newmark "; 242 | else 243 | setup_this=yes 244 | fi 245 | 246 | if [ -n "$rdevip" -a "$rdevip" != "${DEVNUM}" ]; then 247 | eval " mark_remove=\$rdev_${rdevip}_mark "; 248 | if [ -n "$mark_remove" -a "$mark_remove" != "remove" ]; then 249 | net_log $"error in ifcfg-${parent_device}: files" 250 | return 1 251 | fi 252 | if [ "$mark_remove" != "remove" ]; then 253 | eval " rdev_${rdevip}_mark=remove "; 254 | /sbin/ip addr flush dev $parent_device label $parent_device:$rdevip 255 | fi 256 | fi 257 | 258 | fi 259 | 260 | if [ "$setup_this" = "freshen" ] ; then 261 | # we can do the freshen stuff right now 262 | /sbin/ip addr change ${IPADDR}/${PREFIX} brd ${BROADCAST} 263 | fi 264 | 265 | if is_true "$setup_this"; then 266 | if [ "${parent_device}" != "lo" ] && ! is_false "${ARPCHECK}" && \ 267 | is_available ${parent_device} && \ 268 | ( grep -qswi "up" /sys/class/net/${parent_device}/operstate || grep -qswi "1" /sys/class/net/${parent_device}/carrier ) ; then 269 | echo $"Determining if IP address ${IPADDR} is already in use for device ${parent_device}…" 270 | ARPING=$(/sbin/arping -c 2 -w ${ARPING_WAIT:-3} -D -I ${parent_device} ${IPADDR}) 271 | if [ $? = 1 ]; then 272 | ARPINGMAC=$(echo $ARPING | sed -ne 's/.*\[\(.*\)\].*/\1/p') 273 | net_log $"Error, some other host ($ARPINGMAC) already uses address ${IPADDR}." 274 | return 1 275 | fi 276 | fi 277 | 278 | /sbin/ip addr add ${IPADDR}/${PREFIX} brd ${BROADCAST} \ 279 | dev ${parent_device} label ${DEVICE} 280 | 281 | # update ARP cache of neighboring computers: 282 | if ! is_false "${ARPUPDATE}" && [ "${REALDEVICE}" != "lo" ]; then 283 | /sbin/arping -q -A -c 1 -w ${ARPING_UPDATE_WAIT:-3} -I ${parent_device} ${IPADDR} 284 | ( sleep 2; 285 | /sbin/arping -q -U -c 1 -w ${ARPING_UPDATE_WAIT:-3} -I ${parent_device} ${IPADDR} ) > /dev/null 2>&1 < /dev/null & 286 | fi 287 | 288 | ! is_false "$IPV6INIT" && \ 289 | /etc/sysconfig/network-scripts/ifup-ipv6 ${DEVICE} 290 | 291 | if ! is_true "$NO_ALIASROUTING"; then 292 | 293 | GATEWAYDEV=$network_GATEWAYDEV; 294 | 295 | if [ -n "${GATEWAY}" -a \ 296 | \( -z "${GATEWAYDEV}" -o "${GATEWAYDEV}" = "${DEVICE}" \) ]; then 297 | # set up default gateway, if it isn't already there 298 | if ! is_default_gateway "$GATEWAY"; then 299 | ip route replace default ${METRIC:+metric $METRIC} via ${GATEWAY} dev ${DEVICE} 300 | fi 301 | fi 302 | 303 | /etc/sysconfig/network-scripts/ifup-routes ${DEVICE} ${NAME} 304 | 305 | ifuplocal_queue="$ifuplocal_queue $DEVICE" 306 | fi 307 | fi 308 | } 309 | 310 | if [ "$BASH_VERSINFO" ]; then 311 | shopt -s nullglob 312 | else 313 | allow_null_glob_expansion=foo 314 | fi 315 | 316 | for FILE in ifcfg-${parent_device}:* ; do 317 | is_ignored_file "$FILE" && continue 318 | ini_env 319 | . ./$FILE 320 | [ -z "$DEVICE" ] && DEVICE=${FILE##ifcfg-} 321 | ! is_false "$ONPARENT" && new_interface 322 | unset DEVICE 323 | done 324 | 325 | for FILE in ifcfg-${parent_device}-range* ; do 326 | is_ignored_file "$FILE" && continue 327 | ini_env 328 | . ./$FILE 329 | 330 | ipaddr_prefix=${IPADDR_START%.*} 331 | ipaddr_startnum=${IPADDR_START##*.} 332 | ipaddr_endnum=${IPADDR_END##*.} 333 | 334 | if [ "${IPADDR_START%.*}" != "${IPADDR_END%.*}" ]; then 335 | net_log $"error in $FILE: IPADDR_START and IPADDR_END don't agree" 336 | continue 337 | fi 338 | 339 | if [ $ipaddr_startnum -gt $ipaddr_endnum ]; then 340 | net_log $"error in $FILE: IPADDR_START greater than IPADDR_END" 341 | continue 342 | fi 343 | 344 | ipaddr_num=$ipaddr_startnum 345 | ipaddr_clonenum=$CLONENUM_START 346 | 347 | while [ $ipaddr_num -le $ipaddr_endnum ]; do 348 | IPADDR="$ipaddr_prefix.$ipaddr_num" 349 | DEVICE="$parent_device:$ipaddr_clonenum" 350 | IPV6INIT="no" 351 | ! is_false "$ONPARENT" && new_interface 352 | ipaddr_num=$(($ipaddr_num+1)) 353 | ipaddr_clonenum=$(($ipaddr_clonenum+1)) 354 | done 355 | done 356 | 357 | # 358 | # Remove any devices that should not be around 359 | # 360 | for DEVNUM in $rdev_LIST ; do 361 | eval " rdev_mark=\$rdev_${DEVNUM}_mark " 362 | if [ -z "$rdev_mark" ]; then 363 | /sbin/ip addr flush dev $parent_device label $parent_device:${DEVNUM} 364 | fi 365 | done 366 | 367 | if [ -x /sbin/ifup-local ]; then 368 | for DEVICE in $ifuplocal_queue ; do 369 | /sbin/ifup-local ${DEVICE} 370 | done 371 | fi 372 | -------------------------------------------------------------------------------- /network-scripts/ifup-bnep: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | . /etc/init.d/functions 4 | 5 | cd /etc/sysconfig/network-scripts 6 | . ./network-functions 7 | 8 | [ -f ../network ] && . ../network 9 | 10 | CONFIG=${1} 11 | 12 | source_config 13 | 14 | # On hotplug events, just bring the virtual device up as if it's normal Ethernet 15 | if [ -n "$IN_HOTPLUG" ]; then 16 | exec sh -x /etc/sysconfig/network-scripts/ifup-eth ${CONFIG} $2 17 | fi 18 | 19 | start_panu() 20 | { 21 | PANDARGS="--persist --pidfile=/run/pand-${DEVICE}.pid --ethernet=${DEVICE} --autozap" 22 | [ "${CACHE}" != "no" -a "${CACHE}" != "NO" ] && PANDARGS="${PANDARGS} --cache" 23 | if [ "${REMOTEBDADDR}" = "" ]; then 24 | PANDARGS="${PANDARGS} --search" 25 | else 26 | PANDARGS="${PANDARGS} --connect ${REMOTEBDADDR}" 27 | fi 28 | /usr/bin/pand ${PANDARGS} 29 | } 30 | 31 | start_nap() 32 | { 33 | : 34 | } 35 | 36 | start_gn() 37 | { 38 | : 39 | } 40 | 41 | case "$ROLE" in 42 | PANU) 43 | start_panu 44 | ;; 45 | NAP) 46 | start_nap 47 | ;; 48 | GN) 49 | start_gn 50 | ;; 51 | *) 52 | echo Unknown BNEP mode :$ROLE 53 | ;; 54 | esac 55 | 56 | -------------------------------------------------------------------------------- /network-scripts/ifup-ctc: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # /etc/sysconfig/network-scripts/ifup-ctc 4 | # 5 | # the ctc network driver is a point-to-point driver on S/390 machines 6 | # 7 | # To get the ctc module to load automatically at boot, you will need to 8 | # add the following line to /etc/modprobe.conf: 9 | # 10 | # alias ctc0 ctc 11 | # 12 | 13 | cd /etc/sysconfig/network-scripts 14 | . ./network-functions 15 | 16 | . /etc/sysconfig/network 17 | 18 | CONFIG=$1 19 | [ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG 20 | source_config 21 | 22 | if [ "$2" = "boot" -a "${ONBOOT}" = "no" ] ; then 23 | exit 24 | fi 25 | [ -n "${MTU}" ] && ip link set dev ${DEVICE} mtu ${MTU} 26 | 27 | [ -z "$PREFIX" ] && eval $(/bin/ipcalc --prefix ${IPADDR} ${NETMASK}) 28 | ip addr add ${IPADDR} peer ${GATEWAY}/${PREFIX} dev ${DEVICE} 29 | set_link_up ${DEVICE} 30 | # Wait for the device to come up - the chandev'ified ctc driver can take 31 | # quite a while... 32 | timeout=0 33 | while ! ping -w 30 -c 1 ${GATEWAY} &>/dev/null; do 34 | timeout=$(($timeout + 1)) 35 | if [ $timeout = 20 ]; then 36 | net_log $"ERROR: ${DEVICE} did not come up!" 37 | break 38 | fi 39 | done 40 | 41 | if [ "${NETWORK}" != "" ] ; then 42 | ip route add to ${GATEWAY} metric 1 dev ${DEVICE} 43 | fi 44 | 45 | if [ "${GATEWAY}" != "" ]; then 46 | if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then 47 | # set up default gateway 48 | ip route replace default ${METRIC:+metric $METRIC} via ${GATEWAY} 49 | fi 50 | fi 51 | 52 | /etc/sysconfig/network-scripts/ifup-post $1 53 | -------------------------------------------------------------------------------- /network-scripts/ifup-eth: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Network Interface Configuration System 3 | # Copyright (c) 1996-2014 Red Hat, Inc. all rights reserved. 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License, version 2, 7 | # as published by the Free Software Foundation. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, write to the Free Software 16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 | 18 | . /etc/init.d/functions 19 | 20 | cd /etc/sysconfig/network-scripts 21 | . ./network-functions 22 | 23 | [ -f ../network ] && . ../network 24 | 25 | CONFIG=${1} 26 | 27 | need_config "${CONFIG}" 28 | 29 | source_config 30 | 31 | if [ "${BOOTPROTO}" = "bootp" -o "${BOOTPROTO}" = "dhcp" ]; then 32 | DYNCONFIG=true 33 | fi 34 | 35 | # load the module associated with that device 36 | # /sbin/modprobe ${REALDEVICE} 37 | is_available ${REALDEVICE} 38 | 39 | # bail out, if the MAC does not fit 40 | if [ -n "${HWADDR}" ]; then 41 | FOUNDMACADDR=$(get_hwaddr ${REALDEVICE}) 42 | if [ "${FOUNDMACADDR}" != "${HWADDR}" -a "${FOUNDMACADDR}" != "${MACADDR}" ]; then 43 | net_log $"Device ${DEVICE} has different MAC address than expected, ignoring." 44 | exit 1 45 | fi 46 | fi 47 | 48 | # Create veth device 49 | if [ "${TYPE}" = "Veth" ]; then 50 | if [ -z "${PEER}" ]; then 51 | net_log $"cannot create veth without peer" 52 | exit 1 53 | fi 54 | if [ ! -d /sys/class/net/${DEVICE} ]; then 55 | ip link add ${DEVICE} type veth peer name ${PEER} type veth 56 | fi 57 | fi 58 | 59 | # If the device is a bridge, create it 60 | if [ "${TYPE}" = "Bridge" ]; then 61 | bridge_opts="" 62 | [ -n "${DELAY}" ] && bridge_opts+="forward_delay ${DELAY} " 63 | if is_true "${STP}"; then 64 | bridge_opts+="stp_state 1 " 65 | elif is_false "${STP}"; then 66 | bridge_opts+="stp_state 0 " 67 | fi 68 | [ -n "${PRIO}" ] && bridge_opts+="priority ${PRIO} " 69 | [ -n "${AGEING}" ] && bridge_opts+="ageing_time ${AGEING} " 70 | 71 | if [ ! -d /sys/class/net/${DEVICE}/bridge ]; then 72 | ip link add ${DEVICE} type bridge $bridge_opts || exit 1 73 | elif [ -n "${bridge_opts}" ]; then 74 | ip link set dev ${DEVICE} type bridge $bridge_opts || exit 1 75 | fi 76 | unset bridge_opts 77 | 78 | # add the bits to setup driver parameters here 79 | for arg in $BRIDGING_OPTS ; do 80 | key=${arg%%=*}; 81 | value=${arg##*=}; 82 | if [ "${key}" != "multicast_router" -a "${key}" != "hash_max" -a "${key}" != "multicast_snooping" ]; then 83 | echo $value > /sys/class/net/${DEVICE}/bridge/$key 84 | fi 85 | done 86 | 87 | # set LINKDELAY (used as timeout when calling check_link_down()) 88 | # to at least (${DELAY} * 2) + 7 if STP is enabled. This is the 89 | # minimum time required for /sys/class/net/$REALDEVICE/carrier to 90 | # become 1 after "set_link_up $DEVICE" is called. 91 | if is_true "${STP}"; then 92 | if [ -n "${DELAY}" ]; then 93 | forward_delay="${DELAY}" 94 | else 95 | # If the ${DELAY} value is not set by the user, then we need to obtain 96 | # the forward_delay value from kernel first, and convert it to seconds. 97 | # Otherwise STP might not correctly complete the startup before trying 98 | # to obtain an IP address from DHCP. 99 | forward_delay="$(cat /sys/devices/virtual/net/${DEVICE}/bridge/forward_delay)" 100 | forward_delay="$(convert2sec ${forward_delay} centi)" 101 | fi 102 | 103 | forward_delay=$(echo "${forward_delay} * 2 + 7" | bc -q) 104 | 105 | # It's possible we are comparing floating point numbers here, therefore 106 | # we are using 'bc' for comparison. The [ ] and [[ ]] do not work. 107 | (( $(echo "${LINKDELAY:-0} < ${forward_delay}" | bc -l) )) && LINKDELAY=${forward_delay} 108 | 109 | unset forward_delay 110 | fi 111 | fi 112 | 113 | # Create tap device. 114 | if [ "${TYPE}" = "Tap" ]; then 115 | [ -n "${OWNER}" ] && OWNER="user ${OWNER}" 116 | TUNMODE="mode tap" 117 | [[ ${DEVICE} == tun* ]] && TUNMODE="mode tun" 118 | ip tuntap add ${TUNMODE} ${OWNER} dev ${DEVICE} > /dev/null 119 | fi 120 | 121 | # Team master initialization. 122 | if [ -n "${TEAM_CONFIG}" ] && [ ! "${DEVICETYPE}" = "Team" ] && [ -x ./ifup-Team ]; then 123 | ./ifup-Team ${CONFIG} $2 124 | fi 125 | 126 | if [ -z "${REALDEVICE}" ]; then 127 | net_log $"Device name does not seem to be present." 128 | exit 1 129 | fi 130 | 131 | # now check the real state 132 | is_available_wait ${REALDEVICE} ${DEVTIMEOUT} || { 133 | if [ -n "$alias" ]; then 134 | net_log $"$alias device ${DEVICE} does not seem to be present, delaying initialization." 135 | else 136 | net_log $"Device ${DEVICE} does not seem to be present, delaying initialization." 137 | fi 138 | exit 1 139 | } 140 | 141 | 142 | # this isn't the same as the MAC in the configuration filename. It is 143 | # available as a configuration option in the config file, forcing the kernel 144 | # to think an ethernet card has a different MAC address than it really has. 145 | if [ -n "${MACADDR}" ]; then 146 | ip link set dev ${DEVICE} address ${MACADDR} 147 | fi 148 | if [ -n "${MTU}" ]; then 149 | ip link set dev ${DEVICE} mtu ${MTU} 150 | fi 151 | 152 | # is the device wireless? If so, configure wireless device specifics 153 | is_wireless_device ${DEVICE} && . ./ifup-wireless 154 | 155 | # Team slave device? 156 | if [ -n "${TEAM_MASTER}" ] && [ ! "${DEVICETYPE}" = "TeamPort" ] && [ -x ./ifup-TeamPort ]; then 157 | ./ifup-TeamPort ${CONFIG} $2 158 | ethtool_set 159 | exit 0 160 | fi 161 | 162 | # slave device? 163 | if is_true "${SLAVE}" && is_false "${ISALIAS}" && [ -n "${MASTER}" ]; then 164 | install_bonding_driver ${MASTER} 165 | grep -wq "${DEVICE}" /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null || { 166 | /sbin/ip link set dev ${DEVICE} down 167 | echo "+${DEVICE}" > /sys/class/net/${MASTER}/bonding/slaves 2>/dev/null 168 | } 169 | ethtool_set 170 | 171 | exit 0 172 | fi 173 | 174 | # Bonding initialization. For DHCP, we need to enslave the devices early, 175 | # so it can actually get an IP. 176 | if is_false "$ISALIAS" && is_bonding_device ${DEVICE}; then 177 | install_bonding_driver ${DEVICE} 178 | set_link_up ${DEVICE} 179 | for device in $(LANG=C grep -l "^[[:space:]]*MASTER=['\"]\?${DEVICE}['\"]\?\([[:space:]#]\|$\)" /etc/sysconfig/network-scripts/ifcfg-*) ; do 180 | is_ignored_file "$device" && continue 181 | /sbin/ifup ${device##*/} || net_log "Unable to start slave device ${device##*/} for master ${DEVICE}." warning 182 | done 183 | 184 | [ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY} 185 | 186 | # add the bits to setup the needed post enslavement parameters 187 | for arg in $BONDING_OPTS ; do 188 | key=${arg%%=*}; 189 | value=${arg##*=}; 190 | if [ "${key}" = "primary" ]; then 191 | echo $value > /sys/class/net/${DEVICE}/bonding/$key 192 | fi 193 | done 194 | fi 195 | 196 | # If the device is part of a bridge, add the device to the bridge 197 | if [ -n "${BRIDGE}" ]; then 198 | if [ ! -d /sys/class/net/${BRIDGE}/bridge ]; then 199 | ip link add ${BRIDGE} type bridge 2>/dev/null 200 | fi 201 | /sbin/ip addr flush dev ${DEVICE} 2>/dev/null 202 | set_link_up ${DEVICE} 203 | ethtool_set 204 | [ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY} 205 | ip link set dev ${DEVICE} master ${BRIDGE} 206 | # add the bits to setup driver parameters here 207 | for arg in $BRIDGING_OPTS ; do 208 | key=${arg%%=*}; 209 | value=${arg##*=}; 210 | echo $value > /sys/class/net/${DEVICE}/brport/$key 211 | done 212 | # Upon adding a device to a bridge, 213 | # it's necessary to make radvd reload its config 214 | [ -r /run/radvd/radvd.pid ] && kill -HUP $(cat /run/radvd/radvd.pid) 215 | exit 0 216 | fi 217 | 218 | if [ -n "${DYNCONFIG}" ] && [ -x /sbin/dhclient ]; then 219 | if is_true "${PERSISTENT_DHCLIENT}"; then 220 | ONESHOT=""; 221 | else 222 | ONESHOT="-1"; 223 | fi; 224 | generate_config_file_name 225 | generate_lease_file_name 226 | 227 | # Initialize the dhclient args and obtain the hostname options if needed: 228 | DHCLIENTARGS="${DHCLIENTARGS} ${ONESHOT} -q ${DHCLIENTCONF} -lf ${LEASEFILE} -pf /run/dhclient-${DEVICE}.pid" 229 | set_hostname_options DHCLIENTARGS 230 | 231 | echo 232 | echo -n $"Determining IP information for ${DEVICE}..." 233 | if ! is_true "${PERSISTENT_DHCLIENT}" && check_link_down ${DEVICE}; then 234 | echo $" failed; no link present. Check cable?" 235 | exit 1 236 | fi 237 | 238 | ethtool_set 239 | 240 | if /sbin/dhclient ${DHCLIENTARGS} ${DEVICE} ; then 241 | echo $" done." 242 | dhcpipv4="good" 243 | else 244 | echo $" failed." 245 | if is_true "${IPV4_FAILURE_FATAL}"; then 246 | exit 1 247 | fi 248 | if is_false "$IPV6INIT" || ! is_true "$DHCPV6C"; then 249 | exit 1 250 | fi 251 | net_log "Unable to obtain IPv4 DHCP address ${DEVICE}." warning 252 | fi 253 | # end dynamic device configuration 254 | else 255 | if [ -z "${IPADDR}" -a -z "${IPADDR0}" -a -z "${IPADDR1}" -a -z "${IPADDR2}" ]; then 256 | # enable device without IP, useful for e.g. PPPoE 257 | set_link_up ${REALDEVICE} 258 | ethtool_set 259 | [ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY} 260 | else 261 | 262 | expand_config 263 | 264 | [ -n "${ARP}" ] && \ 265 | ip link set dev ${REALDEVICE} $(toggle_value arp $ARP) 266 | 267 | if ! set_link_up ${REALDEVICE} ; then 268 | net_log $"Failed to bring up ${DEVICE}." 269 | exit 1 270 | fi 271 | 272 | ethtool_set 273 | 274 | [ -n "${LINKDELAY}" ] && /bin/sleep ${LINKDELAY} 275 | 276 | if [ "${DEVICE}" = "lo" ]; then 277 | SCOPE="scope host" 278 | else 279 | SCOPE=${SCOPE:-} 280 | fi 281 | 282 | if [ -n "$SRCADDR" ]; then 283 | SRC="src $SRCADDR" 284 | else 285 | SRC= 286 | fi 287 | 288 | # set IP address(es) 289 | for idx in {0..256} ; do 290 | if [ -z "${ipaddr[$idx]}" ]; then 291 | break 292 | fi 293 | 294 | if ! LC_ALL=C ip addr ls ${REALDEVICE} | LC_ALL=C grep -q "${ipaddr[$idx]}/${prefix[$idx]}" ; then 295 | if [ "${REALDEVICE}" != "lo" ] && ! is_false "${arpcheck[$idx]}"; then 296 | for (( tries=0; tries<${ARPING_TRIES:=1}; tries++ )); do 297 | ARPING=$(/sbin/arping -c 2 -w ${ARPING_WAIT:-3} -D -I ${REALDEVICE} ${ipaddr[$idx]}) 298 | [ "$?" -eq 0 ] && break 299 | ARPINGMAC=$(echo $ARPING | sed -ne 's/.*\[\(.*\)\].*/\1/p') 300 | if [ -n "${ARPINGMAC}" ]; then 301 | net_log $"Error, some other host ($ARPINGMAC) already uses address ${ipaddr[$idx]}." 302 | exit 1 303 | fi 304 | done 305 | if [ "${tries}" -eq "${ARPING_TRIES}" ]; then 306 | net_log $"arping failed after $tries tries" 307 | exit 1 308 | fi 309 | fi 310 | 311 | if ! ip addr add ${ipaddr[$idx]}/${prefix[$idx]} \ 312 | brd ${broadcast[$idx]:-+} dev ${REALDEVICE} ${SCOPE} label ${DEVICE}; then 313 | net_log $"Error adding address ${ipaddr[$idx]} for ${DEVICE}." 314 | fi 315 | fi 316 | 317 | if [ -n "$SRCADDR" ]; then 318 | sysctl -w "net.ipv4.conf.${SYSCTLDEVICE}.arp_filter=1" >/dev/null 2>&1 319 | fi 320 | 321 | # update ARP cache of neighboring computers 322 | if ! is_false "${arpupdate[$idx]}" && [ "${REALDEVICE}" != "lo" ]; then 323 | /sbin/arping -q -A -c 1 -w ${ARPING_UPDATE_WAIT:-3} -I ${REALDEVICE} ${ipaddr[$idx]} 324 | ( sleep 2; 325 | /sbin/arping -q -U -c 1 -w ${ARPING_UPDATE_WAIT:-3} -I ${REALDEVICE} ${ipaddr[$idx]} ) > /dev/null 2>&1 < /dev/null & 326 | fi 327 | 328 | # set lifetime of address to forever 329 | ip addr change ${ipaddr[$idx]}/${prefix[$idx]} dev ${REALDEVICE} valid_lft forever preferred_lft forever 330 | done 331 | 332 | # Set a default route. 333 | if ! is_false "${DEFROUTE}" && [ -z "${GATEWAYDEV}" -o "${GATEWAYDEV}" = "${REALDEVICE}" ]; then 334 | # set up default gateway. replace if one already exists 335 | if [ -n "${GATEWAY}" ] && [ "$(ipcalc --network ${GATEWAY} ${netmask[0]} 2>/dev/null)" = "NETWORK=${NETWORK}" ]; then 336 | ip route replace default ${METRIC:+metric $METRIC} \ 337 | ${EXTRA_ROUTE_OPTS} \ 338 | via ${GATEWAY} ${WINDOW:+window $WINDOW} ${SRC} \ 339 | ${GATEWAYDEV:+dev $GATEWAYDEV} || 340 | net_log $"Error adding default gateway ${GATEWAY} for ${DEVICE}." 341 | elif [ "${GATEWAYDEV}" = "${DEVICE}" ]; then 342 | ip route replace default ${METRIC:+metric $METRIC} \ 343 | ${EXTRA_ROUTE_OPTS} \ 344 | ${SRC} ${WINDOW:+window $WINDOW} dev ${REALDEVICE} || 345 | net_log $"Error adding default gateway for ${REALDEVICE}." 346 | fi 347 | fi 348 | fi 349 | fi 350 | 351 | # Add Zeroconf route. 352 | if [ -z "${NOZEROCONF}" ] && is_false "${ISALIAS}" && [ "${REALDEVICE}" != "lo" ]; then 353 | ip route add 169.254.0.0/16 dev ${REALDEVICE} metric $((1000 + $(cat /sys/class/net/${REALDEVICE}/ifindex))) scope link 354 | fi 355 | 356 | if [ "${TYPE}" = "Bridge" ]; then 357 | for arg in $BRIDGING_OPTS ; do 358 | key=${arg%%=*}; 359 | value=${arg##*=}; 360 | if [ "${key}" = "multicast_router" -o "${key}" = "hash_max" -o "${key}" = "multicast_snooping" ]; then 361 | echo $value > /sys/class/net/${DEVICE}/bridge/$key 362 | fi 363 | done 364 | fi 365 | 366 | # IPv6 initialisation? 367 | /etc/sysconfig/network-scripts/ifup-ipv6 ${CONFIG} 368 | if is_true "${DHCPV6C}" && [ -x /sbin/dhclient ]; then 369 | 370 | # Assign interface into a firewalld zone so we can 371 | # obtain the IPv6 via DHCPv6 (empty ZONE means default): 372 | if [ "${REALDEVICE}" != "lo" ]; then 373 | dbus-send --print-reply --system --dest=org.fedoraproject.FirewallD1 \ 374 | /org/fedoraproject/FirewallD1 \ 375 | org.fedoraproject.FirewallD1.zone.changeZoneOfInterface \ 376 | string:"${ZONE}" string:"${DEVICE}" \ 377 | > /dev/null 2>&1 378 | fi 379 | 380 | generate_config_file_name 6 381 | generate_lease_file_name 6 382 | echo 383 | echo -n $"Determining IPv6 information for ${DEVICE}..." 384 | 385 | # Initialize the dhclient args for IPv6 and obtain the hostname options if needed: 386 | if is_true "${PERSISTENT_DHCLIENT_IPV6}"; then 387 | ONESHOT=""; 388 | else 389 | ONESHOT="-1"; 390 | fi; 391 | 392 | DHCLIENTARGS="-6 ${ONESHOT} ${DHCPV6C_OPTIONS} ${DHCLIENTCONF} -lf ${LEASEFILE} -pf /run/dhclient6-${DEVICE}.pid ${DEVICE}" 393 | set_hostname_options DHCLIENTARGS 394 | 395 | if /sbin/dhclient $DHCLIENTARGS; then 396 | echo $" done." 397 | else 398 | echo $" failed." 399 | if [ "${dhcpipv4}" = "good" -o -n "${IPADDR}" ]; then 400 | net_log "Unable to obtain IPv6 DHCP address ${DEVICE}." warning 401 | else 402 | exit 1 403 | fi 404 | fi 405 | fi 406 | 407 | exec /etc/sysconfig/network-scripts/ifup-post ${CONFIG} ${2} 408 | -------------------------------------------------------------------------------- /network-scripts/ifup-ippp: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # ifup-ippp 4 | # 5 | # This script is normally called from the ifup script when it detects an ippp device. 6 | 7 | . /etc/init.d/functions 8 | 9 | cd /etc/sysconfig/network-scripts 10 | . ./network-functions 11 | 12 | # Get global network configuration 13 | [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network 14 | 15 | GATEWAY="" 16 | 17 | # set device 18 | CONFIG=$1 19 | [ -f "${CONFIG}" ] || CONFIG=ifcfg-${1} 20 | source_config 21 | 22 | if [ "${2}" = "boot" -a "${ONBOOT}" = "no" ]; then 23 | exit 24 | fi 25 | 26 | if [ ! -f /var/lock/subsys/isdn ] && [ -x /etc/init.d/isdn ] ; then 27 | /etc/init.d/isdn start 28 | fi 29 | 30 | # check that ipppd is available for syncppp 31 | if [ "$ENCAP" = "syncppp" ]; then 32 | if [ ! -x /sbin/ipppd ] && [ ! -x /usr/sbin/ipppd ] ; then 33 | net_log $"ipppd does not exist or is not executable" info ifup-ippp 34 | exit 1 35 | fi 36 | fi 37 | 38 | # check that isdnctrl is available 39 | if [ ! -x /sbin/isdnctrl ] && [ ! -x /usr/sbin/isdnctrl ] ; then 40 | net_log $"isdnctrl does not exist or is not executable" info ifup-ippp 41 | exit 1 42 | fi 43 | 44 | # check all ISDN devices 45 | if ! isdnctrl list all >/dev/null 2>&1 ; then 46 | net_log $"cannot list ISDN devices" info ifup-ippp 47 | exit 1 48 | fi 49 | 50 | # check if device already is configured 51 | isdnctrl list $DEVICE >/dev/null 2>&1 && exit 0 52 | 53 | function log_echo() 54 | { 55 | net_log $"$*" info ifup-ippp 56 | } 57 | 58 | function log_isdnctrl() 59 | { 60 | net_log $"$*" info ifup-ippp 61 | isdnctrl $* >/dev/null 2>&1 || exit 1 62 | } 63 | 64 | function create_option_file() 65 | { 66 | umask 066 67 | echo "$1" > /etc/ppp/ioption-secret-$DEVICE 68 | umask 022 69 | } 70 | 71 | function start_ibod() 72 | { 73 | # don't start ibod, if it's running 74 | [ -f /var/lock/subsys/ibod ] && return 75 | 76 | device=$1 77 | if [ -f /etc/isdn/ibod.cf ] && [ -x /usr/sbin/ibod ] ; then 78 | ibod $device & 79 | pid=$(pidof ibod) 80 | [ -n "$pid" ] && touch /var/lock/subsys/ibod 81 | fi 82 | } 83 | 84 | function addprovider() 85 | { 86 | options= 87 | if [ -z "$PHONE_OUT" ]; then 88 | log_echo "Error: $1: no outgoing phone number set" 89 | return 1 90 | fi 91 | 92 | # set the encapsulation mode 93 | [ -z "$ENCAP" ] && ENCAP="syncppp" 94 | 95 | # set the dial mode 96 | [ -z "$DIALMODE" ] && DIALMODE="off" 97 | 98 | [ "$AUTH" = "none" -o "$AUTH" = "noauth" -o -z "$AUTH" ] && AUTH="-pap -chap" 99 | 100 | # set layer-2/3 protocol 101 | [ -z "$L2_PROT" ] && L2_PROT="hdlc" 102 | [ -z "$L3_PROT" ] && L3_PROT="trans" 103 | 104 | # check local/remote IP 105 | [ -z "$IPADDR" ] && IPADDR="0.0.0.0" 106 | [ -z "$GATEWAY" ] && GATEWAY="0.0.0.0" 107 | 108 | # set default route 109 | is_true "$DEFROUTE" && options="$options defaultroute deldefaultroute" 110 | 111 | # set authentication 112 | _auth=$(echo "$AUTH" | sed 's/[a-z -]*//g') 113 | if [ -n "$_auth" ]; then 114 | if [ -z "$USER" ] && ! is_true "$DIALIN"; then 115 | log_echo " Error: $1 (syncppp) user is not set" 116 | return 1 117 | fi 118 | if ! is_true "$DIALIN"; then 119 | # we should hide the user name, so i add user name to option file. 120 | if [ "$AUTH" = "-pap +chap" ]; then 121 | create_option_file "name \"$USER\"" 122 | else 123 | create_option_file "user \"$USER\"" 124 | fi 125 | options="$options file /etc/ppp/ioption-secret-$DEVICE" 126 | fi 127 | 128 | # authentication options: 129 | # +pap and/or +chap does not work correct by dialout - remove 130 | # them if it's configured as dialout 131 | is_true "$DIALIN" || AUTH=$(echo "$AUTH" | sed 's/+[a-z]*//g') 132 | fi 133 | 134 | # add ISDN device 135 | log_isdnctrl addif $DEVICE 136 | 137 | # set local MSN 138 | [ -z "$MSN" ] || log_isdnctrl eaz $DEVICE $MSN 139 | 140 | # set dialout numbers 141 | if echo $COUNTRYCODE | grep ":" >/dev/null 2>&1 ; then 142 | COUNTRYCODE="$(echo $COUNTRYCODE | cut -f 2 -d ':')" 143 | [ "$COUNTRYCODE" = "0" ] && COUNTRYCODE= 144 | else 145 | COUNTRYCODE= 146 | fi 147 | for i in $PHONE_OUT; do 148 | log_isdnctrl addphone $DEVICE out $COUNTRYCODE$PREFIX$AREACODE$i 149 | done 150 | for i in $PHONE_IN; do 151 | log_isdnctrl addphone $DEVICE in $i 152 | done 153 | 154 | # set layer-2/3 protocol 155 | log_isdnctrl l2_prot $DEVICE $L2_PROT 156 | log_isdnctrl l3_prot $DEVICE $L3_PROT 157 | 158 | # set encapsulation 159 | log_isdnctrl encap $DEVICE $ENCAP 160 | 161 | # set dialmode 162 | log_isdnctrl dialmode $DEVICE $DIALMODE 163 | 164 | [ -n "$SECURE" ] && log_isdnctrl secure $DEVICE $SECURE 165 | [ -n "$HUPTIMEOUT" ] && log_isdnctrl huptimeout $DEVICE $HUPTIMEOUT 166 | [ -n "$CHARGEHUP" ] && log_isdnctrl chargehup $DEVICE $CHARGEHUP 167 | [ -n "$CHARGEINT" ] && log_isdnctrl chargeint $DEVICE $CHARGEINT 168 | 169 | [ -n "$IHUP" ] && log_isdnctrl ihup $DEVICE $IHUP 170 | 171 | # set the number of dial atempts for each number 172 | [ -n "$DIALMAX" ] && log_isdnctrl dialmax $DEVICE $DIALMAX 173 | 174 | # set callback 175 | if [ "$CALLBACK" = "out" -o "$CALLBACK" = "in" ] ; then 176 | log_isdnctrl callback $DEVICE $CALLBACK 177 | else 178 | log_isdnctrl callback $DEVICE off 179 | fi 180 | [ -n "$CBDELAY" ] && log_isdnctrl cbdelay $DEVICE $CBDELAY 181 | [ -n "$CBHUP" ] && log_isdnctrl cbhup $DEVICE $CBHUP 182 | 183 | options="$options ipparam $DEVNAME" 184 | 185 | [ "$ENCAP" = "syncppp" ] && log_isdnctrl pppbind $DEVICE 186 | 187 | if [ "$IPADDR" = "0.0.0.0" ]; then 188 | options="$options ipcp-accept-local" 189 | else 190 | if ! is_true "$DIALIN"; then 191 | options="$options noipdefault" 192 | fi 193 | fi 194 | # Add device 195 | options="$options /dev/$DEVICE" 196 | 197 | # set channel bundling 198 | if is_true "$BUNDLING" && [ -n "$SLAVE_DEVICE" ]; then 199 | [ -z "$SLAVE_MSN" ] && SLAVE_MSN="$MSN" 200 | [ -z "$SLAVE_PHONE_OUT" ] && SLAVE_PHONE_OUT="$PHONE_OUT" 201 | [ -z "$SLAVE_PHONE_IN" ] && SLAVE_PHONE_IN="$PHONE_IN" 202 | [ -z "$SLAVE_HUPTIMEOUT" ] && SLAVE_HUPTIMEOUT="$HUPTIMEOUT" 203 | [ -z "$SLAVE_CHARGEHUP" ] && SLAVE_CHARGEHUP="$CHARGEHUP" 204 | [ -z "$SLAVE_CHARGEINT" ] && SLAVE_CHARGEINT="$CHARGEINT" 205 | [ -z "$SLAVE_CBHUP" ] && SLAVE_CBHUP="$CBHUP" 206 | [ -z "$SLAVE_IHUP" ] && SLAVE_IHUP="$IHUP" 207 | [ -z "$SLAVE_DIALMAX" ] && SLAVE_DIALMAX="$DIALMAX" 208 | [ -z "$SLAVE_CALLBACK" ] && SLAVE_CALLBACK="$CALLBACK" 209 | [ -z "$SLAVE_CBDELAY" ] && SLAVE_CBDELAY="$CBDELAY" 210 | if ! is_true "$DIALIN"; then 211 | [ -z "$SLAVE_DIALMODE" ] && SLAVE_DIALMODE="auto" 212 | else 213 | # Master should not dial by default on incoming MPPP 214 | [ -z "$SLAVE_DIALMODE" ] && SLAVE_DIALMODE="$DIALMODE" 215 | fi 216 | 217 | slave=$SLAVE_DEVICE 218 | options="$options /dev/$slave +mp" 219 | 220 | # Create slave and set options 221 | log_isdnctrl addslave $DEVICE $slave 222 | [ -z $SLAVE_MSN ] || log_isdnctrl eaz $slave $SLAVE_MSN 223 | 224 | # set phone number 225 | for i in $SLAVE_PHONE_OUT; do 226 | log_isdnctrl addphone $slave out $COUNTRYCODE$PREFIX$AREACODE$i 227 | done 228 | for i in $SLAVE_PHONE_IN; do 229 | log_isdnctrl addphone $slave in $i 230 | done 231 | 232 | # set layer-2/3 protocol 233 | log_isdnctrl l2_prot $slave $L2_PROT 234 | log_isdnctrl l3_prot $slave $L3_PROT 235 | 236 | # set encapsulation 237 | log_isdnctrl encap $slave $ENCAP 238 | 239 | # set dial mode 240 | log_isdnctrl dialmode $slave $SLAVE_DIALMODE 241 | 242 | [ -n "$SECURE" ] && log_isdnctrl secure $slave $SECURE 243 | [ -n "$SLAVE_HUPTIMEOUT" ] && log_isdnctrl huptimeout $slave $SLAVE_HUPTIMEOUT 244 | [ -n "$SLAVE_CHARGEHUP" ] && log_isdnctrl chargehup $slave $SLAVE_CHARGEHUP 245 | [ -n "$SLAVE_CHARGEINT" ] && log_isdnctrl chargeint $slave $SLAVE_CHARGEINT 246 | [ -n "$SLAVE_IHUP" ] && log_isdnctrl ihup $slave $SLAVE_IHUP 247 | [ -n "$SLAVE_DIALMAX" ] && log_isdnctrl dialmax $slave $SLAVE_DIALMAX 248 | 249 | # set callback 250 | [ -n "$SLAVE_CBHUP" ] && log_isdnctrl cbhup $slave $SLAVE_CBHUP 251 | [ -n "$SLAVE_CALLBACK" ] || SLAVE_CALLBACK="off" 252 | log_isdnctrl callback $slave $SLAVE_CALLBACK 253 | [ -n "$SLAVE_CBDELAY" ] && log_isdnctrl cbdelay $DEVICE $SLAVE_CBDELAY 254 | 255 | # options for master device 256 | [ -n "$SLAVE_DELAY" ] && log_isdnctrl sdelay $DEVICE $SLAVE_DELAY 257 | [ -n "$SLAVE_TRIGGER" ] && log_isdnctrl trigger $DEVICE $SLAVE_TRIGGER 258 | fi 259 | 260 | if [ "$GATEWAY" = "0.0.0.0" ]; then 261 | if ! is_true "$DIALIN"; then 262 | options="$options ipcp-accept-remote" 263 | fi 264 | options="$IPADDR:$GATEWAY $options" 265 | else 266 | options="$options $IPADDR:$GATEWAY" 267 | fi 268 | 269 | # Van Jacobson style TCP/IP header compression and 270 | # VJ connection-ID compression 271 | is_false "$VJ" && options="$options -vj" 272 | is_false "$VJCCOMP" && options="$options -vjccomp" 273 | 274 | # Address/Control compression, protocol field compression, 275 | is_false "$AC" && options="$options -ac" 276 | is_false "$PC" && options="$options -pc" 277 | 278 | # BSD-Compression scheme 279 | if is_true "$BSDCOMP"; then 280 | options="$options bsdcomp 9,9" 281 | else 282 | options="$options -bsdcomp" 283 | fi 284 | # Stac compression 285 | if is_true "$LZS"; then 286 | # supports LZS check mode 3 and 4 287 | [ -n "$LZS_MODE" ] || LZS_MODE="4" 288 | [ "$LZS_MODE" = "3" ] && options="$options lzs 1" 289 | [ "$LZS_MODE" = "4" ] && options="$options lzs 1:4" 290 | fi 291 | 292 | # Set max receive and max transmit units 293 | [ -n "$MRU" ] && options="$options mru $MRU" 294 | [ -n "$MTU" ] && options="$options mtu $MTU" 295 | 296 | # set CBCP protocoll 297 | if is_true "$CBCP"; then 298 | if [ -n "$CBCP_MSN" ] ; then 299 | # User managed callback 300 | options="$options callback $CBCP_MSN" 301 | else 302 | # admin managed callback, it's enabled by default 303 | options="$options callback 6" 304 | fi 305 | else 306 | # Disable CBCP 307 | options="$options -callback-cbcp" 308 | fi 309 | 310 | # set CCP protocoll 311 | is_false "$CCP" && options="$options noccp" 312 | 313 | # set host name 314 | [ -n "$ISDN_HOSTNAME" ] && options="$options remotename $ISDN_HOSTNAME" 315 | 316 | # Set authentication 317 | for i in $AUTH ; do 318 | options="$options $i" 319 | done 320 | 321 | # add ppp options 322 | for i in $PPPOPTIONS ; do 323 | options="$options $i" 324 | done 325 | 326 | # check dns entry 327 | if [ -z "$DNS1" -a -z "$DNS2" ]; then 328 | options="$options ms-get-dns" 329 | else 330 | [ -n "$DNS1" ] && options="$options ms-dns $DNS1" 331 | [ -n "$DNS2" ] && options="$options ms-dns $DNS2" 332 | fi 333 | 334 | # set debug 335 | is_true "$DEBUG" && options="-d $options" 336 | 337 | # set netmask, if available 338 | [ -n "$NETMASK" ] && { 339 | val=$(ipcalc --prefix $IPADDR $NETMASK) 340 | pfx=${val##PREFIX=} 341 | } 342 | # activate ISDN device 343 | net_log $"ip addr add $IPADDR peer $GATEWAY${pfx:/$pfx} dev $DEVICE" info ifup-ippp 344 | ip addr add $IPADDR peer $GATEWAY${pfx:/$pfx} dev $DEVICE 345 | set_link_up ${DEVICE} 346 | 347 | if [ "$ENCAP" = "syncppp" ]; then 348 | # start ipppd daemon 349 | net_log $"ipppd $options $netmask" info ifup-ippp 350 | ipppd $options $netmask >/dev/null 2>&1 351 | 352 | # start ibod daemon 353 | if ! is_true "$DIALIN"; then 354 | is_true "$BUNDLING" && [ -n "$SLAVE_DEVICE" ] && start_ibod $DEVICE 355 | fi 356 | fi 357 | 358 | # set default gateway for dial on demand 359 | if [ "$DIALMODE" = "auto" ] ; then 360 | echo 1 > /proc/sys/net/ipv4/ip_dynaddr 361 | if is_true "$DEFROUTE" ; then 362 | if [ "$GATEWAY" = "0.0.0.0" ]; then 363 | ip route replace default ${METRIC:+metric $METRIC} dev ${DEVICE} >/dev/null 2>&1 364 | else 365 | ip route replace default ${METRIC:+metric $METRIC} via ${GATEWAY} dev ${DEVICE} >/dev/null 2>&1 366 | fi 367 | fi 368 | fi 369 | 370 | # Setup IPv6 371 | if ! is_false "$IPV6INIT" && ! [[ -z "$IPV6ADDR" ]]; then 372 | # Native IPv6 use of device configured, check of encapsulation required 373 | if [ "$ENCAP" = "syncppp" ]; then 374 | echo $"Warning: ipppd (kernel 2.4.x and below) doesn't support IPv6 using encapsulation 'syncppp'" 375 | elif [ "$ENCAP" = "rawip" ]; then 376 | echo $"Warning: link doesn't support IPv6 using encapsulation 'rawip'" 377 | fi 378 | fi 379 | /etc/sysconfig/network-scripts/ifup-ipv6 $CONFIG 380 | } 381 | 382 | addprovider || exit 1 383 | 384 | exit 0 385 | -------------------------------------------------------------------------------- /network-scripts/ifup-ipv6: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # ifup-ipv6 4 | # 5 | # 6 | # Taken from: 7 | # (P) & (C) 2000-2006 by Peter Bieringer 8 | # 9 | # You will find more information on the initscripts-ipv6 homepage at 10 | # http://www.deepspace6.net/projects/initscripts-ipv6.html 11 | # 12 | # RHL integration assistance by Pekka Savola 13 | # 14 | # Version: 2006-07-20 15 | # 16 | # Note: if called (like normally) by /etc/sysconfig/network-scripts/ifup 17 | # exit codes aren't handled by "ifup" 18 | # 19 | # Uses following information from "/etc/sysconfig/network": 20 | # IPV6_DEFAULTDEV=: controls default route (optional) 21 | # IPV6_DEFAULTGW=
: controls default route (optional) 22 | # 23 | # Uses following information from "/etc/sysconfig/network-scripts/ifcfg-$1": 24 | # IPV6INIT=yes|no: controls IPv6 configuration for this interface 25 | # IPV6ADDR=[/]: specify primary static IPv6 address 26 | # IPV6ADDR_SECONDARIES="[/] ..." (optional) 27 | # IPV6_ROUTER=yes|no: controls IPv6 autoconfiguration (no: multi-homed interface without routing) 28 | # IPV6_AUTOCONF=yes|no: controls IPv6 autoconfiguration 29 | # defaults: 30 | # IPV6FORWARDING=yes: IPV6_AUTOCONF=no, IPV6_ROUTER=yes 31 | # IPV6FORWARDING=no: IPV6_AUTOCONF=yes 32 | # IPV6_MTU=: controls IPv6 MTU for this link (optional) 33 | # IPV6_PRIVACY="rfc3041": control IPv6 privacy (optional) 34 | # This script only supports "rfc3041" (if kernel supports it) 35 | # 36 | # Optional for 6to4 tunneling (hardwired name of tunnel device is "tun6to4"): 37 | # IPV6TO4INIT=yes|no: controls 6to4 tunneling setup 38 | # IPV6TO4_RELAY=: IPv4 address of the remote 6to4 relay (default: 192.88.99.1) 39 | # IPV6TO4_MTU=: controls IPv6 MTU for the 6to4 link (optional, default is MTU of interface - 20) 40 | # IPV6TO4_IPV4ADDR=: overwrite local IPv4 address (optional) 41 | # IPV6TO4_ROUTING="-/ ...": information to setup additional interfaces 42 | # Example: IPV6TO4_ROUTING="eth0-:f101::1/64 eth1-:f102::1/64" 43 | # 44 | # Optional for 6to4 tunneling to trigger radvd: 45 | # IPV6_CONTROL_RADVD=yes|no: controls radvd triggering (optional) 46 | # IPV6_RADVD_PIDFILE=: PID file of radvd for sending signals, default is "/run/radvd/radvd.pid" (optional) 47 | # IPV6_RADVD_TRIGGER_ACTION=startstop|reload|restart|SIGHUP: how to trigger radvd (optional, default is SIGHUP) 48 | # 49 | # Required version of radvd to use 6to4 prefix recalculation 50 | # 0.6.2p3 or newer supporting option "Base6to4Interface" 51 | # Required version of radvd to use dynamic ppp links 52 | # 0.7.0 + fixes or newer 53 | # 54 | 55 | 56 | . /etc/sysconfig/network 57 | 58 | cd /etc/sysconfig/network-scripts 59 | . ./network-functions 60 | 61 | CONFIG=$1 62 | [ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG 63 | source_config 64 | 65 | REALDEVICE=${DEVICE%%:*} 66 | DEVICE=$REALDEVICE 67 | 68 | # Test whether IPv6 configuration is disabled for this interface 69 | is_false "$IPV6INIT" && exit 0 70 | 71 | [ -f /etc/sysconfig/network-scripts/network-functions-ipv6 ] || exit 1 72 | . /etc/sysconfig/network-scripts/network-functions-ipv6 73 | 74 | 75 | # IPv6 test, module loaded, exit if system is not IPv6-ready 76 | ipv6_test || exit 1 77 | 78 | # Test device status 79 | ipv6_test_device_status $DEVICE 80 | if [ $? != 0 -a $? != 11 ]; then 81 | # device doesn't exist or other problem occurs 82 | exit 1 83 | fi 84 | 85 | # Setup IPv6 address on specified interface 86 | if [ -n "$IPV6ADDR" ]; then 87 | ipv6_add_addr_on_device $DEVICE $IPV6ADDR || exit 1 88 | fi 89 | 90 | # Get current global IPv6 forwarding 91 | ipv6_global_forwarding_current="$(/sbin/sysctl -e -n net.ipv6.conf.all.forwarding)" 92 | 93 | # Set some proc switches depending on defines 94 | if is_true "$IPV6FORWARDING"; then 95 | # Global forwarding should be enabled 96 | 97 | # Check, if global IPv6 forwarding was already set by global script 98 | if [ $ipv6_global_forwarding_current -ne 1 ]; then 99 | net_log $"Global IPv6 forwarding is enabled in configuration, but not currently enabled in kernel" 100 | net_log $"Please restart network with '/sbin/service network restart'" 101 | fi 102 | 103 | ipv6_local_forwarding=1 104 | ipv6_local_auto=0 105 | ipv6_local_accept_ra=0 106 | if is_false "$IPV6_ROUTER"; then 107 | ipv6_local_forwarding=0 108 | fi 109 | if is_true "$IPV6_AUTOCONF"; then 110 | ipv6_local_auto=1 111 | ipv6_local_accept_ra=2 112 | fi 113 | else 114 | # Global forwarding should be disabled 115 | 116 | # Check, if global IPv6 forwarding was already set by global script 117 | if [ $ipv6_global_forwarding_current -ne 0 ]; then 118 | net_log $"Global IPv6 forwarding is disabled in configuration, but not currently disabled in kernel" 119 | net_log $"Please restart network with '/sbin/service network restart'" 120 | fi 121 | 122 | ipv6_local_forwarding=0 123 | ipv6_local_auto=1 124 | ipv6_local_accept_ra=1 125 | if is_false "$IPV6_AUTOCONF"; then 126 | ipv6_local_auto=0 127 | if ! is_true "$IPV6_FORCE_ACCEPT_RA"; then 128 | ipv6_local_accept_ra=0 129 | fi 130 | fi 131 | fi 132 | 133 | if ! is_false "$IPV6_SET_SYSCTLS"; then 134 | /sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.forwarding=$ipv6_local_forwarding >/dev/null 2>&1 135 | /sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.accept_ra=$ipv6_local_accept_ra >/dev/null 2>&1 136 | /sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.accept_redirects=$ipv6_local_auto >/dev/null 2>&1 137 | /sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.autoconf=$ipv6_local_auto >/dev/null 2>&1 138 | fi 139 | 140 | # Set IPv6 MTU, if given 141 | if [ -n "$IPV6_MTU" ]; then 142 | ipv6_set_mtu $DEVICE $IPV6_MTU 143 | fi 144 | 145 | # Setup additional IPv6 addresses from list, if given 146 | if [ -n "$IPV6ADDR_SECONDARIES" ]; then 147 | for ipv6addr in $IPV6ADDR_SECONDARIES; do 148 | ipv6_add_addr_on_device $DEVICE $ipv6addr 149 | done 150 | fi 151 | 152 | # Enable IPv6 RFC3041 privacy extensions if desired 153 | if [ "$IPV6_PRIVACY" = "rfc3041" ]; then 154 | if ! is_false "$IPV6_SET_SYSCTLS"; then 155 | /sbin/sysctl -e -w net.ipv6.conf.$SYSCTLDEVICE.use_tempaddr=2 >/dev/null 2>&1 156 | if [ $? -ne 0 ]; then 157 | net_log $"Cannot enable IPv6 privacy method '$IPV6_PRIVACY', not supported by kernel" 158 | fi 159 | fi 160 | fi 161 | 162 | # Setup default IPv6 route, check are done by function 163 | if [ -n "$IPV6_DEFAULTDEV" -o -n "$IPV6_DEFAULTGW" ]; then 164 | ipv6_set_default_route "$IPV6_DEFAULTGW" "$IPV6_DEFAULTDEV" "$DEVICE" 165 | fi 166 | 167 | # Setup additional static IPv6 routes on specified interface, if given 168 | if [ -f /etc/sysconfig/static-routes-ipv6 ]; then 169 | LC_ALL=C grep -w "^$DEVICE" /etc/sysconfig/static-routes-ipv6 | while read device args; do 170 | ipv6_add_route $args $DEVICE 171 | done 172 | fi 173 | 174 | # Setup of 6to4, if configured 175 | if is_true "$IPV6TO4INIT"; then 176 | valid6to4config="yes" 177 | 178 | # Test device status of 6to4 tunnel 179 | ipv6_test_device_status tun6to4 180 | if [ $? = 0 ]; then 181 | # device is already up 182 | net_log $"Device 'tun6to4' (from '$DEVICE') is already up, shutdown first" 183 | exit 1 184 | fi 185 | 186 | # Get IPv4 address for global 6to4 prefix calculation 187 | if [ -n "$IPV6TO4_IPV4ADDR" ]; then 188 | # Take special configured from config file (precedence 1) 189 | ipv4addr="$IPV6TO4_IPV4ADDR" 190 | 191 | # Get local IPv4 address from interface 192 | ipv4addrlocal="$(ipv6_get_ipv4addr_of_device $DEVICE)" 193 | if [ -z "$ipv4addrlocal" ]; then 194 | # Take configured from config file 195 | ipv4addrlocal="$IPADDR" 196 | fi 197 | else 198 | # Get IPv4 address from interface first (has precedence 2) 199 | ipv4addr="$(ipv6_get_ipv4addr_of_device $DEVICE)" 200 | if [ -z "$ipv4addr" ]; then 201 | # Take configured from config file (precedence 3) 202 | ipv4addr="$IPADDR" 203 | fi 204 | ipv4addrlocal="$ipv4addr" 205 | fi 206 | 207 | if [ -n "$ipv4addr" ]; then 208 | if ! ipv6_test_ipv4_addr_global_usable $ipv4addr; then 209 | net_log $"Given IPv4 address '$ipv4addr' is not globally usable" info 210 | valid6to4config="no" 211 | fi 212 | if [ -z "$IPV6TO4_RELAY" ]; then 213 | IPV6TO4_RELAY="192.88.99.1" 214 | fi 215 | 216 | # Check/generate relay address 217 | ipv6to4_relay="$(ipv6_create_6to4_relay_address $IPV6TO4_RELAY)" 218 | if [ $? -ne 0 ]; then 219 | valid6to4config="no" 220 | fi 221 | else 222 | net_log $"IPv6to4 configuration needs an IPv4 address on related interface or otherwise specified" info 223 | valid6to4config="no" 224 | fi 225 | 226 | # Setup 6to4 tunnel (hardwired name is "tun6to4"), if config is valid 227 | if is_true "$valid6to4config"; then 228 | # Get MTU of master device 229 | ipv4mtu="$(/sbin/ip link show dev $DEVICE | awk '/\/ { print $5 }')" 230 | if [ -n "$ipv4mtu" ]; then 231 | # IPv6 tunnel MTU is IPv4 MTU minus 20 for IPv4 header 232 | tunnelmtu=$(($ipv4mtu-20)) 233 | fi 234 | 235 | if [ -n "$IPV6TO4_MTU" ]; then 236 | if [ $IPV6TO4_MTU -gt $tunnelmtu ]; then 237 | net_log $"Warning: configured MTU '$IPV6TO4_MTU' for 6to4 exceeds maximum limit of '$tunnelmtu', ignored" warning 238 | else 239 | tunnelmtu=$IPV6TO4_MTU 240 | fi 241 | fi 242 | 243 | ipv6_add_6to4_tunnel tun6to4 $ipv4addr "" $tunnelmtu $ipv4addrlocal || exit 1 244 | 245 | # Add route to for compatible addresses (removed later again) 246 | ipv6_add_route "::/96" "::" tun6to4 247 | 248 | # Add default route, if device matches 249 | if [ "$IPV6_DEFAULTDEV" = "tun6to4" ]; then 250 | if [ -n "$IPV6_DEFAULTGW" ]; then 251 | net_log $"Warning: interface 'tun6to4' does not support 'IPV6_DEFAULTGW', ignored" warning 252 | fi 253 | ipv6_set_default_route $ipv6to4_relay tun6to4 254 | fi 255 | 256 | # Add static routes 257 | if [ -f /etc/sysconfig/static-routes-ipv6 ]; then 258 | LC_ALL=C grep -w "^tun6to4" /etc/sysconfig/static-routes-ipv6 | while read device network gateway; do 259 | if [ -z "$network" ]; then 260 | continue 261 | fi 262 | if [ -z "$gateway" ]; then 263 | gateway="$ipv6to4_relay" 264 | fi 265 | ipv6_add_route $network $gateway tun6to4 266 | done 267 | fi 268 | 269 | # Setup additional static IPv6 routes (newer config style) 270 | if [ -f "/etc/sysconfig/network-scripts/route6-tun6to4" ]; then 271 | sed -ne 's/#.*//' -e '/[^[:space:]]/p' /etc/sysconfig/network-scripts/route6-tun6to4 | while read line; do 272 | if echo "$line" | LC_ALL=C grep -vq 'via'; then 273 | # Add gateway if missing 274 | line="$line via $ipv6to4_relay" 275 | fi 276 | /sbin/ip -6 route add $line 277 | done 278 | fi 279 | 280 | # Cleanup autmatically generated autotunnel (not needed for 6to4) 281 | /sbin/ip -6 route del ::/96 dev tun6to4 282 | /sbin/ip -6 addr del "::$ipv4addrlocal/128" dev tun6to4 283 | 284 | if is_true "$IPV6_CONTROL_RADVD"; then 285 | # RADVD is in use, so forwarding of IPv6 packets should be enabled, display warning 286 | if [ $ipv6_global_forwarding_current -ne 1 ]; then 287 | net_log $"Using 6to4 and RADVD IPv6 forwarding usually should be enabled, but it isn't" warning 288 | fi 289 | 290 | if [ -n "$IPV6TO4_ROUTING" ]; then 291 | ipv6to4prefix="$(ipv6_create_6to4_prefix $ipv4addr)" 292 | if [ -n "$ipv6to4prefix" ]; then 293 | # Add route to local networks 294 | for devsuf in $IPV6TO4_ROUTING; do 295 | dev="${devsuf%%-*}" 296 | suf="$(echo $devsuf | awk -F- '{ print $2 }')" 297 | ipv6_add_addr_on_device ${dev} ${ipv6to4prefix}${suf} 298 | done 299 | else 300 | net_log $"Error occurred while calculating the IPv6to4 prefix" 301 | fi 302 | else 303 | net_log $"radvd control enabled, but config is not complete" 304 | fi 305 | 306 | # Control running radvd 307 | ipv6_trigger_radvd up "$IPV6_RADVD_TRIGGER_ACTION" $IPV6_RADVD_PIDFILE 308 | fi 309 | else 310 | net_log $"6to4 configuration is not valid" 311 | exit 1 312 | fi 313 | fi 314 | 315 | #wait for all global IPv6 addresses to leave the "tentative" state 316 | ipv6_wait_tentative $DEVICE 317 | -------------------------------------------------------------------------------- /network-scripts/ifup-plip: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | cd /etc/sysconfig/network-scripts 4 | . ./network-functions 5 | 6 | CONFIG=$1 7 | source_config 8 | 9 | if [ "foo$2" = "fooboot" -a "${ONBOOT}" = "no" ]; then 10 | exit 11 | fi 12 | 13 | [ -z "$PREFIX" ] && eval $(/bin/ipcalc --prefix ${IPADDR} ${NETMASK}) 14 | ip addr add ${IPADDR} peer ${REMIP}/${PREFIX} dev ${DEVICE} 15 | set_link_up ${DEVICE} 16 | ip route add ${NETWORK} dev ${DEVICE} 17 | 18 | . /etc/sysconfig/network 19 | 20 | if [ "${GATEWAY}" != "" ]; then 21 | if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then 22 | # set up default gateway 23 | ip route replace default ${METRIC:+metric $METRIC} via ${GATEWAY} 24 | fi 25 | fi 26 | 27 | /etc/sysconfig/network-scripts/ifup-post $1 28 | -------------------------------------------------------------------------------- /network-scripts/ifup-plusb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # /etc/sysconfig/network-scripts/ifup-plusb 4 | # 5 | # the plusb network driver is a USB host-host cable based on the Prolific 6 | # chip. It works a lot like the plip driver. 7 | # 8 | # To get the plusb module to load automatically at boot, you will need to 9 | # add the following lines to /etc/conf.modules: 10 | # 11 | # alias plusb0 plusb 12 | # 13 | 14 | cd /etc/sysconfig/network-scripts 15 | . ./network-functions 16 | 17 | CONFIG=$1 18 | source_config 19 | 20 | if [ "foo$2" = "fooboot" -a "${ONBOOT}" = "no" ] 21 | then 22 | exit 23 | fi 24 | 25 | [ -z "$PREFIX" ] && eval $(/bin/ipcalc --prefix ${IPADDR} ${NETMASK}) 26 | 27 | if [ ${BROADCAST} != "" ] ; then 28 | ip addr add ${IPADDR} peer ${REMIP}/${PREFIX} broadcast ${BROADCAST} dev ${DEVICE} 29 | else 30 | ip addr add ${IPADDR} peer ${REMIP}/${PREFIX} dev ${DEVICE} 31 | fi 32 | set_link_up ${DEVICE} 33 | 34 | . /etc/sysconfig/network 35 | 36 | if [ "${GATEWAY}" != "" ]; then 37 | if [ "${GATEWAYDEV}" = "" -o "${GATEWAYDEV}" = "${DEVICE}" ]; then 38 | # set up default gateway 39 | ip route replace default ${METRIC:+metric $METRIC} via ${GATEWAY} 40 | fi 41 | fi 42 | 43 | /etc/sysconfig/network-scripts/ifup-post $1 44 | -------------------------------------------------------------------------------- /network-scripts/ifup-post: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Source the general functions for is_true() and is_false(): 4 | . /etc/init.d/functions 5 | 6 | cd /etc/sysconfig/network-scripts 7 | . ./network-functions 8 | 9 | [ -f ../network ] && . ../network 10 | 11 | unset REALDEVICE 12 | if [ "$1" = --realdevice ] ; then 13 | REALDEVICE=$2 14 | shift 2 15 | fi 16 | 17 | CONFIG=$1 18 | source_config 19 | 20 | [ -z "$REALDEVICE" ] && REALDEVICE=$DEVICE 21 | 22 | if is_false "$ISALIAS"; then 23 | /etc/sysconfig/network-scripts/ifup-aliases ${DEVICE} ${CONFIG} 24 | fi 25 | 26 | if ! is_true "$NOROUTESET"; then 27 | /etc/sysconfig/network-scripts/ifup-routes ${REALDEVICE} ${DEVNAME} 28 | fi 29 | 30 | 31 | if ! is_false "${PEERDNS}" || is_true "${RESOLV_MODS}"; then 32 | # Obtain the DNS entries when using PPP if necessary: 33 | [ -n "${MS_DNS1}" ] && DNS1="${MS_DNS1}" 34 | [ -n "${MS_DNS2}" ] && DNS2="${MS_DNS2}" 35 | 36 | # Remove duplicate DNS entries and shift them, if necessary: 37 | update_DNS_entries 38 | 39 | # Determine what regexp we should use (for testing below): 40 | if [ -n "${DNS3}" ]; then 41 | grep_regexp="[^#]?nameserver[[:space:]]+${DNS1}[^#]?nameserver[[:space:]]+${DNS2}[^#]?nameserver[[:space:]]+${DNS3}" 42 | elif [ -n "${DNS2}" ]; then 43 | grep_regexp="[^#]?nameserver[[:space:]]+${DNS1}[^#]?nameserver[[:space:]]+${DNS2}" 44 | elif [ -n "${DNS1}" ]; then 45 | grep_regexp="[^#]?nameserver[[:space:]]+${DNS1}" 46 | else 47 | # No DNS entries used at all ->> match everything. 48 | grep_regexp=".*" 49 | fi 50 | 51 | # Test if the search field needs updating, or 52 | # if the nameserver entries order should be updated: 53 | if [ -n "${DOMAIN}" ] && ! grep -q "^search.*${DOMAIN}.*$" /etc/resolv.conf || 54 | ! tr --delete '\n' < /etc/resolv.conf | grep -E -q "${grep_regexp}"; then 55 | 56 | if tmp_file=$(mktemp); then 57 | search_str='' 58 | 59 | while read line; do 60 | case ${line} in 61 | 62 | # Skip nameserver entries when at least one DNS option was given 63 | # (at this stage we know that we have to update all the nameserver 64 | # enries anyway -- see below), or copy them if we are changing just 65 | # the 'search' field in /etc/resolv.conf: 66 | nameserver*) 67 | if [[ "${grep_regexp}" != ".*" ]]; then 68 | continue 69 | else 70 | echo "${line}" >> "${tmp_file}" 71 | fi 72 | ;; 73 | 74 | domain* | search*) 75 | if [ -n "${DOMAIN}" ]; then 76 | read search value < <(echo ${line}) 77 | search_str+=" ${value}" 78 | else 79 | echo "${line}" >> "${tmp_file}" 80 | fi 81 | ;; 82 | 83 | # Keep the rest of the /etc/resolv.conf as it was: 84 | *) 85 | echo "${line}" >> "${tmp_file}" 86 | ;; 87 | esac 88 | done < /etc/resolv.conf 89 | 90 | # Insert the domain into 'search' field: 91 | if [ -n "${DOMAIN}" ]; then 92 | echo "search ${DOMAIN}${search_str}" >> "${tmp_file}" 93 | fi 94 | 95 | # Add the requested nameserver entries: 96 | [ -n "${DNS1}" ] && echo "nameserver ${DNS1}" >> "${tmp_file}" 97 | [ -n "${DNS2}" ] && echo "nameserver ${DNS2}" >> "${tmp_file}" 98 | [ -n "${DNS3}" ] && echo "nameserver ${DNS3}" >> "${tmp_file}" 99 | 100 | # Backup resolv.conf only if it doesn't exist already: 101 | ! [ -f /etc/resolv.conf.save ] && cp -af /etc/resolv.conf /etc/resolv.conf.save 102 | 103 | # Maintain permissions, but set umask in case it doesn't exist: 104 | umask_old=$(umask) 105 | umask 022 106 | 107 | # Update the resolv.conf: 108 | change_resolv_conf "${tmp_file}" 109 | 110 | rm -f "${tmp_file}" 111 | umask ${umask_old} 112 | unset tmp_file search_str umask_old 113 | else 114 | net_log $"/etc/resolv.conf was not updated: failed to create temporary file" 'err' 'ifup-post' 115 | fi 116 | fi 117 | 118 | unset grep_regexp 119 | fi 120 | 121 | # don't set hostname on ppp/slip connections 122 | if [ "$2" = "boot" -a \ 123 | "${DEVICE}" != lo -a \ 124 | "${DEVICETYPE}" != "ppp" -a \ 125 | "${DEVICETYPE}" != "slip" ]; then 126 | if need_hostname; then 127 | IPADDR=$(LANG=C ip -o -4 addr ls dev ${DEVICE} | awk '{ print $4 ; exit }') 128 | eval $(/bin/ipcalc --silent --hostname ${IPADDR} ; echo "status=$?") 129 | if [ "$status" = "0" ]; then 130 | set_hostname $HOSTNAME 131 | fi 132 | fi 133 | fi 134 | 135 | # Set firewall ZONE for this device (empty ZONE means default): 136 | if [ "${REALDEVICE}" != "lo" ]; then 137 | dbus-send --print-reply --system --dest=org.fedoraproject.FirewallD1 \ 138 | /org/fedoraproject/FirewallD1 \ 139 | org.fedoraproject.FirewallD1.zone.changeZoneOfInterface \ 140 | string:"${ZONE}" string:"${DEVICE}" \ 141 | > /dev/null 2>&1 142 | fi 143 | 144 | if [ -x /sbin/ifup-local ]; then 145 | /sbin/ifup-local ${DEVICE} 146 | fi 147 | 148 | exit 0 149 | -------------------------------------------------------------------------------- /network-scripts/ifup-routes: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | # 3 | # adds static routes which go through device $1 4 | 5 | . /etc/sysconfig/network-scripts/network-functions 6 | 7 | if [ -z "$1" ]; then 8 | echo $"usage: ifup-routes []" 9 | exit 1 10 | fi 11 | 12 | MATCH='^[[:space:]]*(\#.*)?$' 13 | 14 | handle_file () { 15 | . $1 16 | routenum=0 17 | 18 | # print a warning if ADDRESS is not starting at ADDRESS0 19 | if [ "x$(eval echo '$'ADDRESS$routenum)x" == "xx" ]; then 20 | net_log $"Route entries are not sequentially ordered. Skipping $1 file" warning 21 | exit 1 22 | fi 23 | 24 | while [ "x$(eval echo '$'ADDRESS$routenum)x" != "xx" ]; do 25 | eval $(ipcalc -p $(eval echo '$'ADDRESS$routenum) $(eval echo '$'NETMASK$routenum)) 26 | line="$(eval echo '$'ADDRESS$routenum)/$PREFIX" 27 | if [ "x$(eval echo '$'GATEWAY$routenum)x" != "xx" ]; then 28 | line="$line via $(eval echo '$'GATEWAY$routenum)" 29 | fi 30 | line="$line dev $2" 31 | 32 | /sbin/ip route add $line || { 33 | net_log $"Failed to add route ${line}, using ip route replace instead." warning 34 | /sbin/ip route replace $line 35 | } 36 | 37 | routenum=$(($routenum+1)) 38 | done 39 | } 40 | 41 | handle_ip_file() { 42 | local f t type= file=$1 proto="-4" 43 | f=${file##*/} 44 | t=${f%%-*} 45 | type=${t%%6} 46 | if [ "$type" != "$t" ]; then 47 | proto="-6" 48 | fi 49 | { cat "$file" ; echo ; } | while read line; do 50 | if [[ ! "$line" =~ $MATCH ]]; then 51 | /sbin/ip $proto $type add $line 52 | 53 | if [ $? != 0 ] && [ "$type" == "route" ] ; then 54 | net_log $"Failed to add route ${line}, using ip route replace instead." warning 55 | /sbin/ip $proto route replace $line 56 | fi 57 | fi 58 | done 59 | } 60 | 61 | FILES="/etc/sysconfig/network-scripts/route-$1 /etc/sysconfig/network-scripts/route6-$1" 62 | if [ -n "$2" -a "$2" != "$1" ]; then 63 | FILES="$FILES /etc/sysconfig/network-scripts/route-$2 /etc/sysconfig/network-scripts/route6-$2" 64 | fi 65 | 66 | for file in $FILES; do 67 | if [ -f "$file" ]; then 68 | if grep -Eq '^[[:space:]]*ADDRESS[0-9]+=' $file ; then 69 | # new format 70 | handle_file $file ${1%:*} 71 | else 72 | # older format 73 | handle_ip_file $file 74 | fi 75 | fi 76 | done 77 | 78 | 79 | # Red Hat network configuration format 80 | NICK=${2:-$1} 81 | CONFIG="/etc/sysconfig/network-scripts/$NICK.route" 82 | [ -f $CONFIG ] && handle_file $CONFIG $1 83 | 84 | 85 | # Routing rules 86 | FILES="/etc/sysconfig/network-scripts/rule-$1 /etc/sysconfig/network-scripts/rule6-$1" 87 | if [ -n "$2" -a "$2" != "$1" ]; then 88 | FILES="$FILES /etc/sysconfig/network-scripts/rule-$2 /etc/sysconfig/network-scripts/rule6-$2" 89 | fi 90 | 91 | for file in $FILES; do 92 | if [ -f "$file" ]; then 93 | handle_ip_file $file 94 | fi 95 | done 96 | -------------------------------------------------------------------------------- /network-scripts/ifup-sit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # ifup-sit 4 | # 5 | # 6 | # Taken from: 7 | # (P) & (C) 2000-2003 by Peter Bieringer 8 | # 9 | # You will find more information on the initscripts-ipv6 homepage at 10 | # http://www.deepspace6.net/projects/initscripts-ipv6.html 11 | # 12 | # RHL integration assistance by Pekka Savola 13 | # 14 | # Version: 2003-09-08 15 | # 16 | # Uses following information from /etc/sysconfig/network: 17 | # IPV6_DEFAULTDEV=: controls default route (optional) 18 | # IPV6_DEFAULTGW=
: controls default route (optional) 19 | # 20 | # Uses following information from /etc/sysconfig/network-scripts/ifcfg-$1: 21 | # DEVICE= 22 | # IPV6INIT=yes|no: controls IPv6 configuration for this interface 23 | # IPV6_MTU=: controls IPv6 MTU for this link (optional) 24 | # 25 | # For static tunnels 26 | # IPV6TUNNELIPV4=: IPv4 address of remote tunnel endpoint 27 | # IPV6TUNNELIPV4LOCAL=: (optional) local IPv4 address of tunnel 28 | # IPV6ADDR=[/]: (optional) local IPv6 address of a numbered tunnel 29 | # IPV6ADDR_SECONDARIES="[/] ..." (optional) additional local IPv6 addresses 30 | # 31 | 32 | 33 | . /etc/sysconfig/network 34 | 35 | cd /etc/sysconfig/network-scripts 36 | . ./network-functions 37 | 38 | CONFIG=$1 39 | [ -f "$CONFIG" ] || CONFIG=ifcfg-$CONFIG 40 | source_config 41 | 42 | # IPv6 don't need aliases anymore, config is skipped 43 | REALDEVICE=${DEVICE%%:*} 44 | [ "$DEVICE" != "$REALDEVICE" ] && exit 0 45 | 46 | # Test whether IPv6 configuration is disabled for this interface 47 | is_false "$IPV6INIT" && exit 0 48 | 49 | [ -f /etc/sysconfig/network-scripts/network-functions-ipv6 ] || exit 1 50 | . /etc/sysconfig/network-scripts/network-functions-ipv6 51 | 52 | 53 | # IPv6 test, module loaded, exit if system is not IPv6-ready 54 | ipv6_test || exit 1 55 | 56 | # Generic tunnel device sit0 is not supported here 57 | if [ "$DEVICE" = "sit0" ]; then 58 | net_log $"Device '$DEVICE' isn't supported here, use IPV6_AUTOTUNNEL setting and restart (IPv6) networking" 59 | exit 1 60 | fi 61 | 62 | if [ -z "$IPV6TUNNELIPV4" ]; then 63 | net_log $"Missing remote IPv4 address of tunnel, configuration is not valid" 64 | exit 1 65 | fi 66 | 67 | # Test device status 68 | ipv6_test_device_status $DEVICE 69 | if [ $? = 0 ]; then 70 | # device is already up 71 | net_log $"Device '$DEVICE' is already up, please shutdown first" 72 | exit 1 73 | fi 74 | 75 | # Create tunnel 76 | ipv6_add_tunnel_device $DEVICE $IPV6TUNNELIPV4 "" $IPV6TUNNELIPV4LOCAL || exit 1 77 | 78 | # Set IPv6 MTU, if given 79 | if [ -n "$IPV6_MTU" ]; then 80 | ipv6_set_mtu $DEVICE $IPV6_MTU 81 | fi 82 | 83 | # Apply local IPv6 address, if given (numbered tunnel) 84 | if [ -n "$IPV6ADDR" ]; then 85 | ipv6_add_addr_on_device $DEVICE $IPV6ADDR 86 | fi 87 | 88 | # Setup additional IPv6 addresses from list, if given 89 | if [ -n "$IPV6ADDR_SECONDARIES" ]; then 90 | for ipv6addr in $IPV6ADDR_SECONDARIES; do 91 | ipv6_add_addr_on_device $DEVICE $ipv6addr 92 | done 93 | fi 94 | 95 | # Setup default IPv6 route, check are done by function 96 | if [ -n "$IPV6_DEFAULTDEV" -o -n "$IPV6_DEFAULTGW" ]; then 97 | ipv6_set_default_route "$IPV6_DEFAULTGW" "$IPV6_DEFAULTDEV" "$DEVICE" 98 | fi 99 | 100 | # Setup additional static IPv6 routes on specified interface, if given 101 | if [ -f /etc/sysconfig/static-routes-ipv6 ]; then 102 | LC_ALL=C grep -w "^$DEVICE" /etc/sysconfig/static-routes-ipv6 | while read device ipv6route args; do 103 | ipv6_add_route $ipv6route :: $DEVICE 104 | done 105 | fi 106 | 107 | # Setup static routes 108 | /etc/sysconfig/network-scripts/ifup-routes ${REALDEVICE} 109 | -------------------------------------------------------------------------------- /network-scripts/ifup-tunnel: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (C) 1996-2009 Red Hat, Inc. all rights reserved. 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License, version 2, 6 | # as published by the Free Software Foundation. 7 | # 8 | # This program is distributed in the hope that it will be useful, 9 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | # GNU General Public License for more details. 12 | # 13 | # You should have received a copy of the GNU General Public License 14 | # along with this program; if not, write to the Free Software 15 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 16 | 17 | # Thanks to: 18 | # - Razvan Corneliu C.R. Vilt 19 | # - Aaron Hope 20 | # - Sean Millichamp 21 | # for providing the scripts this one is based on 22 | 23 | . /etc/init.d/functions 24 | 25 | cd /etc/sysconfig/network-scripts 26 | . ./network-functions 27 | 28 | CONFIG=$1 29 | need_config "$CONFIG" 30 | source_config 31 | 32 | if [ "$PEER_OUTER_IPADDR" = "$PEER_INNER_IPADDR" ]; then 33 | # Specifying PEER_INNER_IPADDR would automatically add a route to the peer 34 | # through the tunnel, redirecting tunnel packets back to the tunnel and 35 | # creating a dead loop. 36 | unset PEER_INNER_IPADDR 37 | fi 38 | 39 | case "$TYPE" in 40 | GRE) 41 | MODE=gre 42 | proto=-4 43 | /sbin/modprobe ip_gre 44 | ;; 45 | GRE6) 46 | MODE=ip6gre 47 | proto=-6 48 | /sbin/modprobe ip6_gre 49 | ;; 50 | IPIP) 51 | MODE=ipip 52 | proto=-4 53 | /sbin/modprobe ipip 54 | ;; 55 | IPIP6|EXTERNAL) 56 | MODE=ipip6 57 | proto=-6 58 | /sbin/modprobe ip6_tunnel 59 | ;; 60 | *) 61 | net_log $"Invalid tunnel type $TYPE" 62 | exit 1 63 | ;; 64 | esac 65 | 66 | # Generic tunnel devices are not supported here 67 | if [ "$DEVICE" = gre0 -o "$DEVICE" = tunl0 -o "$DEVICE" = ip6tnl0 ]; then 68 | net_log $"Device '$DEVICE' isn't supported as a valid GRE device name." 69 | exit 1 70 | fi 71 | 72 | # Create the tunnel 73 | # The outer addresses are those of the underlying (public) network. 74 | if [ "$TYPE" = 'EXTERNAL' ]; then 75 | /sbin/ip link add "$DEVICE" type ip6tnl external 76 | else 77 | /sbin/ip $proto tunnel add "$DEVICE" mode "$MODE" \ 78 | ${MY_OUTER_IPADDR:+local "$MY_OUTER_IPADDR"} \ 79 | ${PEER_OUTER_IPADDR:+remote "$PEER_OUTER_IPADDR"} \ 80 | ${KEY:+key "$KEY"} ${TTL:+ttl "$TTL"} 81 | fi 82 | 83 | if [ -n "$MTU" ]; then 84 | /sbin/ip link set "$DEVICE" mtu "$MTU" 85 | fi 86 | 87 | # The inner address are used mainly for communication between a gateway 88 | # and a private network. When the peer is configured with an inner address 89 | # contained in the peer's private network or identical to it's public address, 90 | # it need not be specified. 91 | /sbin/ip addr add "$MY_INNER_IPADDR" dev "$DEVICE" \ 92 | ${PEER_INNER_IPADDR:+peer "$PEER_INNER_IPADDR"} 93 | 94 | set_link_up "${DEVICE}" 95 | 96 | # IPv6 initialisation? 97 | /etc/sysconfig/network-scripts/ifup-ipv6 ${CONFIG} 98 | 99 | exec /etc/sysconfig/network-scripts/ifup-post "$CONFIG" "$2" 100 | -------------------------------------------------------------------------------- /network-scripts/ifup-wireless: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Network Interface Configuration System 3 | # Copyright (c) 1996-2009 Red Hat, Inc. all rights reserved. 4 | # 5 | # Based on PCMCIA wireless script by (David Hinds/Jean Tourrilhes) 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License, version 2, 9 | # as published by the Free Software Foundation. 10 | # 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | # GNU General Public License for more details. 15 | # 16 | # You should have received a copy of the GNU General Public License 17 | # along with this program; if not, write to the Free Software 18 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | # 20 | # Configure wireless network device options. See iw(8) for more info. 21 | # Valid variables: 22 | # MODE: Ad-Hoc, Managed, etc. 23 | # ESSID: Name of the wireless network 24 | # FREQ: Frequency to operate on. See CHANNEL 25 | # KEY: Encryption key for WEP. 26 | 27 | # Only meant to be called from ifup. 28 | 29 | cd /etc/sysconfig/network-scripts 30 | . ./network-functions 31 | 32 | IW=${IW:-iw} 33 | 34 | [ "$KEY" ] && KEYS="key d:0:$KEY" 35 | 36 | shopt -s nocasematch 37 | 38 | case "$MODE" in 39 | managed) 40 | if [ "$ESSID" ]; then 41 | $IW dev "$DEVICE" set type managed 42 | $IW dev "$DEVICE" connect -w "$ESSID" $FREQ $KEYS 43 | fi 44 | ;; 45 | ad-hoc) 46 | if [ -n "$ESSID" -a -n "$FREQ" ]; then 47 | $IW dev "$DEVICE" set type ibss 48 | $IW dev "$DEVICE" ibss join "$ESSID" "$FREQ" $KEYS 49 | fi 50 | ;; 51 | monitor) 52 | if [ "$FREQ" ]; then 53 | $IW dev "$DEVICE" set type monitor 54 | $IW dev "$DEVICE" set freq "$FREQ" 55 | fi 56 | ;; 57 | esac 58 | 59 | if [ -n "$WOWLAN" ] ; then 60 | PHYDEVICE=$(phy_wireless_device $DEVICE) 61 | iw phy $PHYDEVICE wowlan enable ${WOWLAN} 62 | fi 63 | -------------------------------------------------------------------------------- /network-scripts/init.ipv6-global: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # init.ipv6-global 4 | # 5 | # 6 | # Taken from: init.ipv6-global 7 | # (P) & (C) 2001-2005 by Peter Bieringer 8 | # 9 | # You will find more information on the initscripts-ipv6 homepage at 10 | # http://www.deepspace6.net/projects/initscripts-ipv6.html 11 | # 12 | # RHL integration assistance by Pekka Savola 13 | # 14 | # Version: 2005-01-04 15 | # 16 | # Calling parameters: 17 | # $1: action (currently supported: start|stop|showsysctl) 18 | # $2: position for start|stop (currently supported: pre|post) 19 | # 20 | # Called by hooks from /etc/[rc.d/]init.d/network 21 | # 22 | # Uses following information from /etc/sysconfig/network: 23 | # IPV6FORWARDING=yes|no: controls global IPv6 forwarding (default: no) 24 | # IPV6_AUTOCONF=yes|no: controls global automatic IPv6 configuration 25 | # (default: yes if IPV6FORWARDING=no, no if IPV6FORWARDING=yes) 26 | # IPV6_AUTOTUNNEL=yes|no: controls automatic IPv6 tunneling (default: no) 27 | # IPV6_DEFAULTGW= [optional] 28 | # IPV6_DEFAULTDEV= [optional] 29 | # 30 | 31 | . /etc/sysconfig/network 32 | 33 | cd /etc/sysconfig/network-scripts 34 | . ./network-functions 35 | 36 | # Get action and hook position 37 | ACTION="$1" 38 | POSITION="$2" 39 | 40 | [ -f /etc/sysconfig/network-scripts/network-functions-ipv6 ] || exit 1 41 | . /etc/sysconfig/network-scripts/network-functions-ipv6 42 | 43 | # Initialize IPv6, depending on caller option 44 | case $ACTION in 45 | start) 46 | case $POSITION in 47 | pre) 48 | # IPv6 test, module loaded, exit if system is not IPv6-ready 49 | ipv6_test || exit 1 50 | 51 | if is_true "$IPV6FORWARDING"; then 52 | ipv6_global_forwarding=1 53 | ipv6_global_auto=0 54 | else 55 | ipv6_global_forwarding=0 56 | if is_false "$IPV6_AUTOCONF"; then 57 | ipv6_global_auto=0 58 | else 59 | ipv6_global_auto=1 60 | fi 61 | fi 62 | 63 | if ! is_false "$IPV6_SET_SYSCTLS"; then 64 | # Reset IPv6 sysctl switches for "all", "default" and still existing devices 65 | for i in /proc/sys/net/ipv6/conf/* ; do 66 | interface=${i##*/} 67 | sinterface=${interface/.//} 68 | # Host/Router behaviour for the interface 69 | /sbin/sysctl -e -w net.ipv6.conf.$sinterface.forwarding=$ipv6_global_forwarding >/dev/null 2>&1 70 | 71 | # Autoconfiguration and redirect handling for Hosts 72 | /sbin/sysctl -e -w net.ipv6.conf.$sinterface.accept_ra=$ipv6_global_auto >/dev/null 2>&1 73 | /sbin/sysctl -e -w net.ipv6.conf.$sinterface.accept_redirects=$ipv6_global_auto >/dev/null 2>&1 74 | done 75 | fi 76 | ;; 77 | 78 | post) 79 | # IPv6 test, module loaded, exit if system is not IPv6-ready 80 | ipv6_test || exit 1 81 | 82 | if is_true "$IPV6_AUTOTUNNEL"; then 83 | ipv6_enable_autotunnel 84 | # autotunnel interface doesn't require a MTU setup 85 | fi 86 | 87 | ## Add some routes which should never appear on the wire 88 | # Unreachable IPv4-only addresses, normally blocked by source address selection 89 | /sbin/ip route add unreach ::ffff:0.0.0.0/96 90 | # Unreachable IPv4-mapped addresses 91 | /sbin/ip route add unreach ::0.0.0.0/96 92 | # Unreachable 6to4: IPv4 multicast, reserved, limited broadcast 93 | /sbin/ip route add unreach 2002:e000::/19 94 | # Unreachable 6to4: IPv4 loopback 95 | /sbin/ip route add unreach 2002:7f00::/24 96 | # Unreachable 6to4: IPv4 private (RFC 1918) 97 | /sbin/ip route add unreach 2002:0a00::/24 98 | /sbin/ip route add unreach 2002:ac10::/28 99 | /sbin/ip route add unreach 2002:c0a8::/32 100 | # Unreachable 6to4: IPv4 private (APIPA / DHCP link-local) 101 | /sbin/ip route add unreach 2002:a9fe::/32 102 | # Unreachable IPv6: 6bone test addresses 103 | /sbin/ip route add unreach 3ffe:ffff::/32 104 | 105 | # Set default route for autotunnel, if specified 106 | if [ "$IPV6_DEFAULTDEV" = "sit0" ] && is_true "$IPV6_AUTOTUNNEL"; then 107 | if [ -n "$IPV6_DEFAULTGW" ]; then 108 | ipv6_set_default_route $IPV6_DEFAULTGW $IPV6_DEFAULTDEV sit0 109 | elif [ -n "$IPV6_DEFAULTDEV" ]; then 110 | ipv6_set_default_route "" $IPV6_DEFAULTDEV sit0 111 | fi 112 | fi 113 | ;; 114 | 115 | *) 116 | echo "Usage: $0 $1 {pre|post}" 117 | ;; 118 | 119 | esac 120 | ;; 121 | 122 | stop) 123 | case $POSITION in 124 | pre) 125 | ;; 126 | 127 | post) 128 | # IPv6 test, no module loaded, exit if system is not IPv6-ready 129 | ipv6_test testonly || exit 0 130 | 131 | if ! is_false "$IPV6_SET_SYSCTLS"; then 132 | for i in /proc/sys/net/ipv6/conf/* ; do 133 | interface=${i##*/} 134 | sinterface=${interface/.//} 135 | # Assume Host behaviour 136 | /sbin/sysctl -e -w net.ipv6.conf.$sinterface.forwarding=0 >/dev/null 2>&1 137 | 138 | # Disable autoconfiguration and redirects 139 | /sbin/sysctl -e -w net.ipv6.conf.$sinterface.accept_ra=0 >/dev/null 2>&1 140 | /sbin/sysctl -e -w net.ipv6.conf.$sinterface.accept_redirects=0 >/dev/null 2>&1 141 | done 142 | fi 143 | 144 | # Cleanup still existing tunnel devices 145 | ipv6_cleanup_tunnel_devices 146 | 147 | # Shut down generic tunnel interface now 148 | if ipv6_test_device_status sit0 ; then 149 | /sbin/ip link set sit0 down 150 | fi 151 | ;; 152 | 153 | *) 154 | echo "Usage: $0 $1 {pre|post}" 155 | ;; 156 | 157 | esac 158 | ;; 159 | 160 | *) 161 | echo $"Usage: $0 {start|stop|reload|restart|showsysctl}" 162 | exit 1 163 | ;; 164 | esac 165 | -------------------------------------------------------------------------------- /po/.gitignore: -------------------------------------------------------------------------------- 1 | *.mo 2 | -------------------------------------------------------------------------------- /po/Makefile: -------------------------------------------------------------------------------- 1 | # Basic Makefile for compiling & installing the translation files. 2 | # 3 | # Supports standard GNU Makefile variables for specifying the paths: 4 | # * prefix 5 | # * sbindir 6 | # * libexecdir 7 | # * datarootdir 8 | # * datadir 9 | # * sysconfdir 10 | # * DESTDIR 11 | # 12 | 13 | SHELL = /bin/bash 14 | 15 | # Normally /usr/local is used. However, it does not make sense for us to use it 16 | # here, as it just complicates things even further. 17 | prefix = /usr 18 | sbindir = $(prefix)/sbin 19 | libexecdir = $(prefix)/libexec 20 | datarootdir = $(prefix)/share 21 | datadir = $(datarootdir) 22 | sysconfdir = /etc 23 | 24 | NLSDIR = $(datadir)/locale 25 | NLSPACKAGE = initscripts 26 | 27 | CATALOGS = $(shell ls *.po) 28 | FMTCATALOGS = $(patsubst %.po,%.mo,$(CATALOGS)) 29 | 30 | POTFILES = $(shell ls ../network-scripts/* | grep -v ifcfg-) \ 31 | ..$(sbindir)/service \ 32 | ..$(libexecdir)/import-state \ 33 | ..$(libexecdir)/loadmodules \ 34 | ..$(libexecdir)/readonly-root \ 35 | ..$(sysconfdir)/rc.d/init.d/*\ 36 | 37 | 38 | all: $(NLSPACKAGE).pot $(FMTCATALOGS) 39 | 40 | $(NLSPACKAGE).pot: $(POTFILES) 41 | if [ -z "$(PYTHON)" ]; then \ 42 | ./xgettext_sh.py $(POTFILES) > $(NLSPACKAGE).po; \ 43 | else \ 44 | $(PYTHON) xgettext_sh.py $(POTFILES) > $(NLSPACKAGE).po; \ 45 | fi 46 | if cmp -s $(NLSPACKAGE).po $(NLSPACKAGE).pot; then \ 47 | rm -f $(NLSPACKAGE).po; \ 48 | else \ 49 | mv $(NLSPACKAGE).po $(NLSPACKAGE).pot; \ 50 | fi 51 | 52 | %.mo: %.po 53 | msgfmt -o $@ $< 54 | 55 | install: all 56 | install -m 0755 -d $(DESTDIR)/$(NLSDIR) 57 | for file in $(CATALOGS); do \ 58 | lang=`basename $$file .po`; \ 59 | mo_file=$$lang.mo; \ 60 | install -m 0755 -d $(DESTDIR)$(NLSDIR)/$$lang; \ 61 | install -m 0755 -d $(DESTDIR)$(NLSDIR)/$$lang/LC_MESSAGES; \ 62 | install -m 0644 $$mo_file $(DESTDIR)/$(NLSDIR)/$$lang/LC_MESSAGES/$(NLSPACKAGE).mo; \ 63 | done 64 | 65 | clean: 66 | rm -f *.mo *.pyc 67 | -------------------------------------------------------------------------------- /po/xgettext_sh.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | # sh_xgettext 3 | # Arnaldo Carvalho de Melo 4 | # Wed Mar 10 10:24:35 EST 1999 5 | # Copyright Conectiva Consultoria e Desenvolvimento de Sistemas LTDA 6 | # 7 | # This program is free software; you can redistribute it and/or modify 8 | # it under the terms of the GNU General Public License as published by 9 | # the Free Software Foundation; either version 2 of the License, or 10 | # (at your option) any later version. 11 | # 12 | # This program is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU General Public License 18 | # along with this program; if not, write to the Free Software Foundation, 19 | # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | # 21 | # Changelog 22 | # Mon May 31 1999 Wanderlei Antonio Cavassin 23 | # * option --initscripts 24 | 25 | 26 | from sys import argv 27 | import string 28 | import re 29 | 30 | s = {} 31 | pattern = re.compile('[ =]\$"') 32 | 33 | 34 | def xgettext(arq): 35 | line = 0 36 | f = open(arq, "r") 37 | 38 | while 1: 39 | l = f.readline() 40 | 41 | if not l: 42 | break 43 | 44 | line = line + 1 45 | 46 | if l[0:1] == '#': 47 | continue 48 | elif l[0:1] == '\n': 49 | continue 50 | else: 51 | for match in pattern.finditer(l): 52 | pos = match.start() 53 | p1 = l.find('"', pos) + 1 54 | p2 = p1 + 1 55 | 56 | while 1: 57 | p2 = l.find('"', p2) 58 | if p2 == -1: 59 | p2 = p1 60 | break 61 | if l[p2-1] == '\\': 62 | p2 = p2 + 1 63 | else: 64 | break 65 | 66 | text = l[p1:p2] 67 | 68 | if text in s: 69 | s[text].append((arq, line)) 70 | else: 71 | s[text] = [(arq, line)] 72 | 73 | f.close() 74 | 75 | 76 | def print_header(): 77 | print('msgid ""') 78 | print('msgstr ""') 79 | print('"Project-Id-Version: PACKAGE VERSION\\n"') 80 | print('"Report-Msgid-Bugs-To: \\n"') 81 | print('"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\\n"') 82 | print('"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n"') 83 | print('"Last-Translator: FULL NAME \\n"') 84 | print('"Language-Team: LANGUAGE \\n"') 85 | print('"Language: \\n"') 86 | print('"MIME-Version: 1.0\\n"') 87 | print('"Content-Type: text/plain; charset=UTF-8\\n"') 88 | print('"Content-Transfer-Encoding: 8bit\\n"\n') 89 | 90 | 91 | def print_pot(): 92 | print_header() 93 | 94 | for text in list(s.keys()): 95 | print('#:', end=' ') 96 | 97 | for p in s[text]: 98 | print('%s:%d' % p, end=' ') 99 | 100 | if text.find('%') != -1: 101 | print('\n#, c-format', end=' ') 102 | 103 | print('\nmsgid "' + text + '"') 104 | print('msgstr ""\n') 105 | 106 | 107 | def main(): 108 | for a in argv: 109 | xgettext(a) 110 | 111 | print_pot() 112 | 113 | if __name__ == '__main__': 114 | main() 115 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | build/* 2 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | # Basic Makefile for compiling & installing the files. 2 | # 3 | # Supports standard GNU Makefile variables for specifying the paths: 4 | # * prefix 5 | # * bindir 6 | # * sbindir 7 | # * libdir 8 | # * DESTDIR 9 | # 10 | 11 | SHELL = /bin/bash 12 | 13 | # Normally /usr/local is used. However, it does not make sense for us to use it 14 | # here, as it just complicates things even further. 15 | prefix = /usr 16 | bindir = $(prefix)/bin 17 | sbindir = $(prefix)/sbin 18 | libdir = $(prefix)/lib 19 | 20 | CC = gcc 21 | CFLAGS += $(RPM_OPT_FLAGS) -Wall -D_GNU_SOURCE -fPIE 22 | LDFLAGS += $(RPM_LD_FLAGS) -pie -z relro -z now 23 | 24 | PROGS = consoletype genhostid rename_device usleep 25 | INSTALL_PROGS = install-progs 26 | ifndef NO_NETWORK_SCRIPTS 27 | PROGS += usernetctl 28 | INSTALL_PROGS += install-network-scripts 29 | endif 30 | 31 | all: $(PROGS) 32 | 33 | install: $(INSTALL_PROGS) 34 | 35 | install-progs: 36 | install -m 0755 -d $(DESTDIR)$(bindir) 37 | install -m 0755 -d $(DESTDIR)$(sbindir) 38 | install -m 0755 -d $(DESTDIR)$(libdir)/udev 39 | install -m 0755 build/usleep $(DESTDIR)$(bindir) 40 | install -m 0755 build/consoletype $(DESTDIR)$(sbindir) 41 | install -m 0755 build/genhostid $(DESTDIR)$(sbindir) 42 | install -m 0755 build/rename_device $(DESTDIR)$(libdir)/udev 43 | 44 | install-network-scripts: 45 | install -m 0755 build/usernetctl $(DESTDIR)$(sbindir) 46 | 47 | clean: 48 | rm -f build/* 49 | 50 | consoletype: build/consoletype.o 51 | $(CC) $(LDFLAGS) -o build/$@ $^ 52 | 53 | build/consoletype.o: consoletype.c 54 | $(CC) $(CFLAGS) -c -o $@ $^ 55 | 56 | 57 | genhostid: build/genhostid.o 58 | $(CC) $(LDFLAGS) -o build/$@ $^ 59 | 60 | build/genhostid.o: genhostid.c 61 | $(CC) $(CFLAGS) -c -o $@ $^ 62 | 63 | 64 | rename_device: build/rename_device.o 65 | $(CC) $(LDFLAGS) -o build/$@ $^ `pkg-config glib-2.0 --libs` 66 | 67 | build/rename_device.o: rename_device.c 68 | $(CC) $(CFLAGS) -c -o $@ $^ `pkg-config glib-2.0 --cflags` 69 | 70 | 71 | usernetctl: build/usernetctl.o 72 | $(CC) $(LDFLAGS) -o build/$@ $^ 73 | 74 | build/usernetctl.o: usernetctl.c 75 | $(CC) $(CFLAGS) -c -o $@ $^ 76 | 77 | 78 | usleep: build/usleep.o 79 | $(CC) $(LDFLAGS) -o build/$@ $^ -lpopt 80 | 81 | build/usleep.o: usleep.c 82 | $(CC) $(CFLAGS) -c -o $@ $^ 83 | -------------------------------------------------------------------------------- /src/build/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fedora-sysv/initscripts/b0c7eeac5e10db18c6dc7cef63f042789e175d24/src/build/.gitkeep -------------------------------------------------------------------------------- /src/consoletype.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1999-2009 Red Hat, Inc. All rights reserved. 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License, version 2, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software Foundation, 15 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | * 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | int main(int argc, char **argv) 28 | { 29 | unsigned char twelve = 12; 30 | char *type; 31 | int maj, min, ret = 0, fg = -1; 32 | struct stat sb; 33 | 34 | fprintf(stderr, "warning: consoletype is now deprecated, and will be removed in the near future!\n" 35 | "warning: use tty (1) instead! More info: 'man 1 tty'\n"); 36 | 37 | fstat(0, &sb); 38 | maj = major(sb.st_rdev); 39 | min = minor(sb.st_rdev); 40 | if (maj != 3 && (maj < 136 || maj > 143)) { 41 | if ((fg = ioctl (0, TIOCLINUX, &twelve)) < 0) { 42 | type = "serial"; 43 | ret = 1; 44 | } else { 45 | #ifdef __powerpc__ 46 | int fd; 47 | char buf[65536]; 48 | 49 | fd = open("/proc/tty/drivers",O_RDONLY); 50 | read(fd, buf, 65535); 51 | if (strstr(buf,"vioconsole /dev/tty")) { 52 | type = "vio"; 53 | ret = 3; 54 | } else { 55 | type = "vt"; 56 | ret = 0; 57 | } 58 | #else 59 | type = "vt"; 60 | ret = 0; 61 | #endif 62 | } 63 | } else { 64 | type = "pty"; 65 | ret = 2; 66 | } 67 | if (argc > 1 && !strcmp(argv[1],"fg")) { 68 | if (fg < 0 || fg != (min-1)) 69 | return 1; 70 | return 0; 71 | } else { 72 | printf("%s\n",type); 73 | return (argc > 1 && !strcmp(argv[1],"stdout")) ? 0 : ret; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/genhostid.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2003-2007 Red Hat, Inc. 2 | * 3 | * This program is free software; you can redistribute it and/or modify 4 | * it under the terms of the GNU General Public License, version 2, 5 | * as published by the Free Software Foundation. 6 | * 7 | * This program is distributed in the hope that it will be useful, 8 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 9 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 | * GNU General Public License for more details. 11 | * 12 | * You should have received a copy of the GNU General Public License 13 | * along with this program; if not, write to the Free Software Foundation, 14 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 15 | * 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | int main (void) 26 | { 27 | struct stat st; 28 | long int n; 29 | 30 | fprintf(stderr, "warning: genhostid is now deprecated, and will be removed in the near future!\n" 31 | "warning: use systemd-machine-id-setup (1) instead! More info: 'man 5 machine-id'\n"); 32 | 33 | /* 34 | * NOTE: gethostid() always returns 32-bit identifier, and st_size field 35 | * of stat structure represents total size of file, in bytes. 36 | */ 37 | 38 | if (stat ("/etc/hostid", &st) == 0 && 39 | S_ISREG (st.st_mode) && st.st_size == 4) { 40 | return 0; 41 | } 42 | 43 | int fd = open ("/dev/random", O_RDONLY); 44 | 45 | if (fd == -1 || read (fd, &n, sizeof (n)) != sizeof (n)) { 46 | srand48 ((long int) time (NULL) ^ (long int) getpid ()); 47 | n = lrand48 (); 48 | } 49 | 50 | return sethostid ((int32_t) n); 51 | } 52 | -------------------------------------------------------------------------------- /src/rename_device.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * rename_device.c: udev helper to rename ethernet devices. 4 | * 5 | * Copyright (C) 2006-2009 Red Hat, Inc. All rights reserved. 6 | * 7 | * This copyrighted material is made available to anyone wishing to use, 8 | * modify, copy, or redistribute it subject to the terms and conditions of the 9 | * GNU General Public License v.2. 10 | * 11 | * This program is distributed in the hope that it will be useful, but WITHOUT 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 14 | * more details. 15 | * 16 | * You should have received a copy of the GNU General Public License along 17 | * with this program; if not, write to the Free Software Foundation, Inc., 18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | #include 37 | 38 | #include 39 | 40 | #include 41 | 42 | #define LOCKFILE "/dev/.rename_device.lock" 43 | 44 | void sighandler(int dummy) { 45 | unlink(LOCKFILE); 46 | _exit(1); 47 | } 48 | 49 | struct netdev { 50 | char *hwaddr; 51 | char *dev; 52 | struct netdev *next; 53 | }; 54 | 55 | struct tmp { 56 | char *src; 57 | char *target; 58 | struct tmp *next; 59 | }; 60 | 61 | struct netdev *configs = NULL; 62 | struct tmp *tmplist = NULL; 63 | 64 | #if defined(__s390__) || defined(__s390x__) 65 | static int is_cdev(const struct dirent *dent) { 66 | char *end = NULL; 67 | 68 | if (strncmp(dent->d_name,"cdev",4)) 69 | return 0; 70 | strtoul(dent->d_name+4,&end, 10); 71 | if (*end) 72 | return 0; 73 | return 1; 74 | } 75 | 76 | static inline char *getdev(char *path, char *ent) { 77 | char *a, *b, *ret; 78 | 79 | asprintf(&a,"%s/%s",path,ent); 80 | b = canonicalize_file_name(a); 81 | ret = strdup(basename(b)); 82 | free(b); 83 | free(a); 84 | return ret; 85 | } 86 | 87 | char *read_subchannels(char *path) { 88 | char *tmp, *ret; 89 | int n, x; 90 | struct dirent **cdevs; 91 | 92 | if ((n = scandir(path, &cdevs, is_cdev, alphasort)) <= 0) 93 | return NULL; 94 | 95 | ret = getdev(path,cdevs[0]->d_name); 96 | for (x = 1 ; x < n ; x++ ) { 97 | if (asprintf(&tmp, "%s,%s", ret, getdev(path, cdevs[x]->d_name)) == -1) 98 | return NULL; 99 | free(ret); 100 | ret = tmp; 101 | } 102 | return ret; 103 | } 104 | 105 | #endif 106 | 107 | /* 108 | * Taken from systemd: 109 | * https://github.com/systemd/systemd/blob/master/src/basic/string-util.c#L49 110 | */ 111 | char* endswith(const char *s, const char *postfix) { 112 | size_t sl, pl; 113 | 114 | sl = strlen(s); 115 | pl = strlen(postfix); 116 | 117 | if (pl == 0) 118 | return (char*) s + sl; 119 | 120 | if (sl < pl) 121 | return NULL; 122 | 123 | if (memcmp(s + sl - pl, postfix, pl) != 0) 124 | return NULL; 125 | 126 | return (char*) s + sl - pl; 127 | } 128 | 129 | int isCfg(const struct dirent *dent) { 130 | if (strncmp(dent->d_name, "ifcfg-",6) || 131 | endswith(dent->d_name, ".rpmnew") != NULL || 132 | endswith(dent->d_name, ".rpmsave") != NULL || 133 | endswith(dent->d_name, ".rpmorig") != NULL || 134 | endswith(dent->d_name, ".orig") != NULL || 135 | endswith(dent->d_name, ".old") != NULL || 136 | endswith(dent->d_name, ".bak") != NULL || 137 | endswith(dent->d_name, "~") != NULL) 138 | return 0; 139 | else 140 | return 1; 141 | } 142 | 143 | static inline char *dequote(char *start, char *end) { 144 | char *c; 145 | //remove comments and trailing whitespace 146 | for (c = start; c && *c; c++) { 147 | c = strchr(c, '#'); 148 | if (!c) 149 | break; 150 | if (c > start && isblank(*(c-1))) { 151 | *c = '\0'; 152 | break; 153 | } 154 | } 155 | 156 | g_strchomp(start); 157 | 158 | if (end==NULL) { 159 | end=start; 160 | while(*end) end++; 161 | } 162 | if (end > start) end--; 163 | if ((*start == '\'' || *start == '\"') && ( *start == *end ) ) { 164 | *end='\0'; 165 | if (startd_name) == -1) 194 | continue; 195 | g_file_get_contents(path, &contents, NULL, NULL); 196 | free(path); 197 | if (!contents) 198 | continue; 199 | lines = g_strsplit(contents,"\n", 0); 200 | for (i = 0; lines[i]; i++) { 201 | if (g_str_has_prefix(lines[i],"DEVICE=")) { 202 | devname = dequote(lines[i] + 7, NULL); 203 | /* ignore alias devices */ 204 | if (strchr(devname,':')) 205 | devname = NULL; 206 | } 207 | #if defined(__s390__) || defined(__s390x__) 208 | if (g_str_has_prefix(lines[i],"SUBCHANNELS=")) { 209 | hwaddr = dequote(lines[i] + 12, NULL); 210 | } else if (g_str_has_prefix(lines[i],"HWADDR=")) { 211 | hwaddr = dequote(lines[i] + 7, NULL); 212 | } 213 | #else 214 | if (g_str_has_prefix(lines[i],"HWADDR=")) { 215 | hwaddr = dequote(lines[i] + 7, NULL); 216 | } 217 | #endif 218 | if (g_str_has_prefix(lines[i],"VLAN=yes")) { 219 | vlan=1; 220 | } 221 | } 222 | if (!devname || !hwaddr || vlan) { 223 | g_free(contents); 224 | g_strfreev(lines); 225 | continue; 226 | } 227 | tmpdev = calloc(1, sizeof(struct netdev)); 228 | tmpdev->dev = g_strstrip(g_strdup(devname)); 229 | tmpdev->hwaddr = g_strstrip(g_strdup(hwaddr)); 230 | if (ret) 231 | tmpdev->next = ret; 232 | ret = tmpdev; 233 | g_free(contents); 234 | g_strfreev(lines); 235 | } 236 | free(cfgs); 237 | return ret; 238 | } 239 | 240 | char *get_hwaddr(char *device) { 241 | char *path = NULL; 242 | char *contents = NULL; 243 | 244 | #if defined(__s390__) || defined(__s390x__) 245 | if (asprintf(&path, "/sys/class/net/%s/device/.", device) == -1) 246 | return NULL; 247 | contents = read_subchannels(path); 248 | 249 | if (contents == NULL) { 250 | if (asprintf(&path, "/sys/class/net/%s/address", device) == -1) 251 | return NULL; 252 | g_file_get_contents(path, &contents, NULL, NULL); 253 | } 254 | 255 | #else 256 | if (asprintf(&path, "/sys/class/net/%s/address", device) == -1) 257 | return NULL; 258 | g_file_get_contents(path, &contents, NULL, NULL); 259 | #endif 260 | free(path); 261 | 262 | return g_strstrip(contents); 263 | } 264 | 265 | char *get_config_by_hwaddr(char *hwaddr, char *current) { 266 | struct netdev *config; 267 | char *first = NULL; 268 | 269 | if (!hwaddr) return NULL; 270 | 271 | for (config = configs; config; config = config->next) { 272 | if (strcasecmp(config->hwaddr, hwaddr) != 0) 273 | continue; 274 | if (!current || !strcasecmp(config->dev, current)) 275 | return config->dev; 276 | if (!first) 277 | first = config->dev; 278 | } 279 | return first; 280 | } 281 | 282 | /* Let's check kernel cmdline and also process ifname= entries 283 | * as they are documented in dracut.cmdline(7) 284 | * Example: ifname=test:aa:bb:cc:dd:ee:ff 285 | */ 286 | char *get_cmdline_by_hwaddr(char *hwaddr) { 287 | gchar *contents; 288 | gchar **entries; 289 | int i; 290 | char *name = NULL; 291 | g_file_get_contents("/proc/cmdline", &contents, NULL, NULL); 292 | entries = g_strsplit(contents," ", 0); 293 | for (i = 0; entries[i]; i++) { 294 | char *c = (char *) entries[i]; 295 | char *n; 296 | 297 | if (!g_str_has_prefix((gchar *)c,"ifname=")) 298 | continue; 299 | 300 | c = strstr(c, "="); 301 | if (c == NULL) 302 | continue; 303 | c++; 304 | n=c; 305 | 306 | c = strstr(c, ":"); 307 | if (c == NULL) 308 | continue; 309 | *c = '\0'; 310 | c++; 311 | 312 | if (!strcasecmp(c, hwaddr)) { 313 | name = strdup(n); 314 | break; 315 | } 316 | } 317 | g_free(contents); 318 | g_strfreev(entries); 319 | return name; 320 | } 321 | 322 | void take_lock() { 323 | int count = 0; 324 | int lockfd; 325 | ssize_t ignored_retval __attribute__((unused)); 326 | 327 | while (1) { 328 | lockfd = open(LOCKFILE, O_RDWR|O_CREAT|O_EXCL, 0644); 329 | if (lockfd != -1) { 330 | char buf[32]; 331 | 332 | snprintf(buf,32,"%d\n",getpid()); 333 | ignored_retval = write(lockfd,buf,strlen(buf)); 334 | close(lockfd); 335 | break; 336 | } else if (errno == EACCES) 337 | break; 338 | 339 | count++; 340 | /* If we've slept for 20 seconds, break the lock. */ 341 | if (count >= 200) { 342 | int fd; 343 | char buf[32]; 344 | int pid; 345 | 346 | fd = open(LOCKFILE, O_RDONLY); 347 | if (fd == -1) 348 | break; 349 | ignored_retval = read(fd,buf,32); 350 | close(fd); 351 | pid = atoi(buf); 352 | if (pid && pid != 1) { 353 | kill(pid,SIGKILL); 354 | } 355 | } 356 | usleep(100000); 357 | continue; 358 | 359 | } 360 | return; 361 | } 362 | 363 | int main(int argc, char **argv) { 364 | char *src, *target, *hw; 365 | struct timeval tv; 366 | 367 | gettimeofday(&tv, NULL); 368 | srand(tv.tv_usec); 369 | take_lock(); 370 | 371 | signal(SIGSEGV,sighandler); 372 | signal(SIGKILL,sighandler); 373 | signal(SIGTERM,sighandler); 374 | signal(SIGSEGV,sighandler); 375 | signal(SIGALRM,sighandler); 376 | alarm(10); 377 | 378 | src = getenv("INTERFACE"); 379 | if (!src) 380 | goto out_unlock; 381 | 382 | configs = get_configs(); 383 | 384 | hw = get_hwaddr(src); 385 | if (!hw) 386 | goto out_unlock; 387 | target = get_cmdline_by_hwaddr(hw); 388 | if (!target) 389 | target = get_config_by_hwaddr(hw, src); 390 | if (!target) 391 | goto out_unlock; 392 | 393 | printf("%s", target); 394 | 395 | out_unlock: 396 | unlink(LOCKFILE); 397 | exit(0); 398 | } 399 | -------------------------------------------------------------------------------- /src/usernetctl.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 1997-2007 Red Hat, Inc. All rights reserved. 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License, version 2, 6 | * as published by the Free Software Foundation. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | * 13 | * You should have received a copy of the GNU General Public License 14 | * along with this program; if not, write to the Free Software Foundation, 15 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 16 | * 17 | */ 18 | 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | 30 | /* This will be running setuid root, so be careful! */ 31 | static const char * safeEnviron[] = { 32 | "PATH=/bin:/sbin:/usr/bin:/usr/sbin", 33 | "HOME=/root", 34 | NULL 35 | }; 36 | 37 | #define FOUND_FALSE -1 38 | #define NOT_FOUND 0 39 | #define FOUND_TRUE 1 40 | 41 | static void 42 | usage(void) { 43 | fprintf(stderr, "usage: usernetctl \n"); 44 | exit(1); 45 | } 46 | 47 | static size_t 48 | testSafe(char *ifaceConfig, int fd) { 49 | struct stat sb; 50 | 51 | /* These shouldn't be symbolic links -- anal, but that's fine w/ mkj. */ 52 | if (fstat(fd, &sb)) { 53 | fprintf(stderr, "failed to stat %s: %s\n", ifaceConfig, 54 | strerror(errno)); 55 | exit(1); 56 | } 57 | 58 | /* Safety/sanity checks. */ 59 | if (!S_ISREG(sb.st_mode)) { 60 | fprintf(stderr, "%s is not a normal file\n", ifaceConfig); 61 | exit(1); 62 | } 63 | 64 | if (sb.st_uid) { 65 | fprintf(stderr, "%s should be owned by root\n", ifaceConfig); 66 | exit(1); 67 | } 68 | 69 | if (sb.st_mode & S_IWOTH) { 70 | fprintf(stderr, "%s should not be world writeable\n", ifaceConfig); 71 | exit(1); 72 | } 73 | 74 | return sb.st_size; 75 | } 76 | 77 | 78 | static int 79 | userCtl(char *file) { 80 | char *buf; 81 | char *contents = NULL; 82 | char *chptr = NULL; 83 | char *next = NULL; 84 | int fd = -1, retval = NOT_FOUND; 85 | size_t size = 0; 86 | 87 | /* Open the file and then test it to see if we like it. This way 88 | we avoid switcheroo attacks. */ 89 | if ((fd = open(file, O_RDONLY)) == -1) { 90 | fprintf(stderr, "failed to open %s: %s\n", file, strerror(errno)); 91 | exit(1); 92 | } 93 | 94 | size = testSafe(file, fd); 95 | if (size > INT_MAX) { 96 | fprintf(stderr, "file %s is too big\n", file); 97 | exit(1); 98 | } 99 | 100 | buf = contents = malloc(size + 2); 101 | if (contents == NULL) { 102 | fprintf(stderr, "failed to allocate memory\n"); 103 | exit(1); 104 | } 105 | 106 | if (read(fd, contents, size) != size) { 107 | perror("error reading device configuration"); 108 | exit(1); 109 | } 110 | close(fd); 111 | 112 | contents[size] = '\n'; 113 | contents[size + 1] = '\0'; 114 | 115 | /* Each pass parses a single line (until an answer is found), The contents 116 | pointer itself points to the beginning of the current line. */ 117 | while (*contents) { 118 | chptr = contents; 119 | while (*chptr != '\n') chptr++; 120 | next = chptr + 1; 121 | while (chptr >= contents && isspace(*chptr)) chptr--; 122 | *(++chptr) = '\0'; 123 | 124 | if (!strncasecmp(contents, "USERCTL=", 8)) { 125 | contents += 8; 126 | if ((contents[0] == '"' && 127 | contents[strlen(contents) - 1] == '"') || 128 | (contents[0] == '\'' && 129 | contents[strlen(contents) - 1] == '\'')) 130 | { 131 | contents++; 132 | contents[strlen(contents) - 1] = '\0'; 133 | } 134 | 135 | if (!strcasecmp(contents, "yes") || !strcasecmp(contents, "true")) 136 | retval = FOUND_TRUE; 137 | else 138 | retval = FOUND_FALSE; 139 | 140 | break; 141 | } 142 | 143 | contents = next; 144 | } 145 | 146 | free(buf); 147 | 148 | return retval; 149 | } 150 | 151 | int 152 | main(int argc, char ** argv) { 153 | char * ifaceConfig; 154 | char * chptr; 155 | char * cmd = NULL; 156 | int report = 0; 157 | char tmp; 158 | int ignored_retval __attribute__((unused)); 159 | 160 | if (argc != 3) usage(); 161 | 162 | if (!strcmp(argv[2], "up")) { 163 | cmd = "./ifup"; 164 | } else if (!strcmp(argv[2], "down")) { 165 | cmd = "./ifdown"; 166 | } else if (!strcmp(argv[2], "report")) { 167 | report = 1; 168 | } else { 169 | usage(); 170 | } 171 | 172 | if (chdir("/etc/sysconfig/network-scripts")) { 173 | fprintf(stderr, "error switching to /etc/sysconfig/network-scripts: " 174 | "%s\n", strerror(errno)); 175 | exit(1); 176 | } 177 | 178 | /* force the interface configuration to be in the current directory */ 179 | chptr = ifaceConfig = argv[1]; 180 | while (*chptr) { 181 | if (*chptr == '/') 182 | ifaceConfig = chptr + 1; 183 | chptr++; 184 | } 185 | 186 | /* automatically prepend "ifcfg-" if it is not specified */ 187 | if (strncmp(ifaceConfig, "ifcfg-", 6)) { 188 | char *temp; 189 | size_t len = strlen(ifaceConfig); 190 | 191 | /* Make sure a wise guys hasn't tried an integer wrap-around or 192 | stack overflow attack. There's no way it could refer to anything 193 | bigger than the largest filename, so cut 'em off there. */ 194 | if (len > PATH_MAX) 195 | exit(1); 196 | 197 | temp = (char *) alloca(len + 7); 198 | strcpy(temp, "ifcfg-"); 199 | /* strcat is safe because we got the length from strlen */ 200 | strcat(temp, ifaceConfig); 201 | ifaceConfig = temp; 202 | } 203 | 204 | if(getuid() != 0) 205 | switch (userCtl(ifaceConfig)) { 206 | char *dash; 207 | 208 | case NOT_FOUND: 209 | /* a `-' will be found at least in "ifcfg-" */ 210 | dash = strrchr(ifaceConfig, '-'); 211 | if (*(dash-1) != 'g') { 212 | /* This was a clone configuration; ask the parent config */ 213 | tmp = *dash; 214 | *dash = '\0'; 215 | if (userCtl(ifaceConfig) == FOUND_TRUE) { 216 | /* exit the switch; users are allowed to control */ 217 | *dash = tmp; 218 | break; 219 | } 220 | *dash = tmp; 221 | } 222 | /* else fall through */ 223 | case FOUND_FALSE: 224 | if (! report) 225 | fprintf(stderr, 226 | "Users are not allowed to control this interface.\n"); 227 | exit(1); 228 | break; 229 | } 230 | 231 | /* looks good to me -- let's go for it if we are changing the interface, 232 | * report good status to the user otherwise */ 233 | 234 | if (report) 235 | exit(0); 236 | 237 | /* pppd wants the real uid to be the same as the effective (god only 238 | knows why when it works fine setuid out of the box) */ 239 | ignored_retval = setuid(geteuid()); 240 | /* Drop user gid (for temp files, SELinux) */ 241 | ignored_retval = setgid(0); 242 | 243 | execle(cmd, cmd, ifaceConfig, NULL, safeEnviron); 244 | fprintf(stderr, "exec of %s failed: %s\n", cmd, strerror(errno)); 245 | 246 | exit(1); 247 | } 248 | -------------------------------------------------------------------------------- /src/usleep.c: -------------------------------------------------------------------------------- 1 | /* 2 | * usleep 3 | * 4 | * Written by Donald Barnes for Red Hat, Inc. 5 | * 6 | * Copyright (c) 1997-2003 Red Hat, Inc. All rights reserved. 7 | * 8 | * This program is free software; you can redistribute it and/or modify 9 | * it under the terms of the GNU General Public License, version 2, 10 | * as published by the Free Software Foundation. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this program; if not, write to the Free Software Foundation, 19 | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 20 | * 21 | */ 22 | 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include "popt.h" 30 | 31 | int main(const int argc, const char **argv) { 32 | unsigned long count; 33 | poptContext optCon; 34 | int showVersion = 0; 35 | int showOot = 0; 36 | int rc; 37 | const char * countStr = NULL; 38 | struct poptOption options[] = { 39 | { "version", 'v', POPT_ARG_NONE, &showVersion, 0, 40 | "Display the version of this program, and exit" }, 41 | { "oot", 'o', POPT_ARG_NONE, &showOot, 0, 42 | "oot says hey!" }, 43 | POPT_AUTOHELP 44 | { 0, 0, 0, 0, 0 } 45 | }; 46 | 47 | optCon = poptGetContext("usleep", argc, argv, options,0); 48 | /*poptReadDefaultConfig(optCon, 1);*/ 49 | poptSetOtherOptionHelp(optCon, "[microseconds]"); 50 | 51 | if ((rc = poptGetNextOpt(optCon)) < -1) { 52 | fprintf(stderr, "usleep: bad argument %s: %s\n", 53 | poptBadOption(optCon, POPT_BADOPTION_NOALIAS), 54 | poptStrerror(rc)); 55 | return 2; 56 | } 57 | 58 | if (showVersion) { 59 | printf("usleep version 1.2\n usleep --help for more info\n"); 60 | return 0; 61 | } 62 | 63 | if (showOot) { 64 | printf("oot says hey!\n"); 65 | return 0; 66 | } 67 | 68 | countStr = poptGetArg(optCon); 69 | 70 | if (countStr == NULL) count = 1; 71 | 72 | else if (countStr && poptGetArg(optCon)) { 73 | fprintf(stderr, "%s: exactly one argument (number of microseconds) " 74 | "must be used\n", argv[0]); 75 | return 2; 76 | } 77 | 78 | else count = strtoul(countStr, NULL, 0); 79 | 80 | fprintf(stderr, "warning: usleep is deprecated, and will be removed in near future!\n" 81 | "warning: use \"sleep %.7g\" instead...\n", count / 1e6); 82 | 83 | usleep(count); 84 | return 0; 85 | } 86 | -------------------------------------------------------------------------------- /usr/lib/systemd/system/import-state.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Import network configuration from initramfs 3 | DefaultDependencies=no 4 | ConditionPathIsReadWrite=/ 5 | ConditionDirectoryNotEmpty=/run/initramfs/state 6 | Conflicts=shutdown.target 7 | Before=shutdown.target emergency.service emergency.target systemd-tmpfiles-setup.service sysinit.target 8 | After=local-fs.target 9 | 10 | [Service] 11 | ExecStart=/usr/libexec/import-state 12 | Type=oneshot 13 | TimeoutSec=0 14 | RemainAfterExit=yes 15 | 16 | [Install] 17 | WantedBy=sysinit.target 18 | -------------------------------------------------------------------------------- /usr/lib/systemd/system/loadmodules.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Load legacy module configuration 3 | DefaultDependencies=no 4 | Conflicts=shutdown.target 5 | Before=sysinit.target shutdown.target 6 | ConditionPathExists=|/etc/rc.modules 7 | ConditionDirectoryNotEmpty=|/etc/sysconfig/modules/ 8 | 9 | [Service] 10 | ExecStart=/usr/libexec/loadmodules 11 | Type=oneshot 12 | TimeoutSec=0 13 | RemainAfterExit=yes 14 | 15 | [Install] 16 | WantedBy=sysinit.target 17 | -------------------------------------------------------------------------------- /usr/lib/systemd/system/netconsole.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Initializes network console logging of kernel messages 3 | ConditionPathExists=/etc/sysconfig/netconsole 4 | After=network-online.target 5 | Wants=network-online.target 6 | 7 | [Service] 8 | ExecStart=/usr/libexec/netconsole start 9 | ExecStop=/usr/libexec/netconsole stop 10 | Type=oneshot 11 | RemainAfterExit=yes 12 | 13 | [Install] 14 | WantedBy=multi-user.target 15 | -------------------------------------------------------------------------------- /usr/lib/systemd/system/readonly-root.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Configure read-only root support 3 | DefaultDependencies=no 4 | Conflicts=shutdown.target 5 | Before=shutdown.target emergency.service emergency.target systemd-tmpfiles-setup.service local-fs.target systemd-random-seed.service 6 | After=systemd-remount-fs.service 7 | 8 | [Service] 9 | ExecStart=/usr/libexec/readonly-root 10 | Type=oneshot 11 | TimeoutSec=0 12 | RemainAfterExit=yes 13 | 14 | [Install] 15 | WantedBy=local-fs.target 16 | -------------------------------------------------------------------------------- /usr/lib/udev/rules.d/60-net.rules: -------------------------------------------------------------------------------- 1 | ACTION=="add", SUBSYSTEM=="net", DRIVERS=="?*", ATTR{type}=="1", PROGRAM="/lib/udev/rename_device", RESULT=="?*", NAME="$result" 2 | -------------------------------------------------------------------------------- /usr/libexec/import-state: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # import-state: import state files from initramfs (e.g. network config) 3 | 4 | # Copy state into root folder: 5 | # ============================ 6 | cd /run/initramfs/state 7 | 8 | IFS_backup=$IFS 9 | IFS=$'\n' # Process find's results line by line 10 | 11 | dirs_found=$(find . -type d) 12 | 13 | for dir in $dirs_found; do 14 | pushd "$dir" > /dev/null 15 | 16 | # Remove initial '.' char from the find's result: 17 | dest_dir="${dir/\./}" 18 | 19 | # Create destination folder if it does not exist (with the same rights): 20 | if [[ -n "$dest_dir" && ! -d "$dest_dir" ]]; then 21 | mkdir -p "$dest_dir" 22 | chmod --reference="$PWD" "$dest_dir" 23 | chown --reference="$PWD" "$dest_dir" 24 | fi 25 | 26 | # Copy all files that are not directory: 27 | find . -mindepth 1 -maxdepth 1 -not -type d -exec cp -av -t "$dest_dir" {} \; > /dev/null 28 | 29 | popd > /dev/null 30 | done 31 | 32 | IFS=$IFS_backup 33 | 34 | 35 | # Run restorecon on the copied files: 36 | # =================================== 37 | if [ -e /sys/fs/selinux/enforce ] && [ -x /usr/sbin/restorecon ]; then 38 | find . -mindepth 1 -print0 | { cd / && xargs --null restorecon -iF; } 39 | fi 40 | -------------------------------------------------------------------------------- /usr/libexec/loadmodules: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Load other user-defined modules 4 | for file in /etc/sysconfig/modules/*.modules ; do 5 | [ -x $file ] && $file 6 | done 7 | 8 | # Load modules (for backward compatibility with VARs) 9 | if [ -f /etc/rc.modules ]; then 10 | /etc/rc.modules 11 | fi 12 | -------------------------------------------------------------------------------- /usr/libexec/netconsole: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # netconsole This loads the netconsole module with the configured parameters. 4 | # 5 | # chkconfig: - 50 50 6 | # description: Initializes network console logging 7 | # config: /etc/sysconfig/netconsole 8 | # 9 | ### BEGIN INIT INFO 10 | # Provides: netconsole 11 | # Required-Start: $network 12 | # Short-Description: Initializes network console logging 13 | # Description: Initializes network console logging of kernel messages. 14 | ### END INIT INFO 15 | 16 | # Copyright 2002 Red Hat, Inc. 17 | # 18 | # Based in part on a shell script by 19 | # Andreas Dilger Sep 26, 2001 20 | 21 | PATH=/sbin:/usr/sbin:$PATH 22 | RETVAL=0 23 | 24 | [ -f /etc/sysconfig/network ] && . /etc/sysconfig/network 25 | 26 | # Source function library. 27 | . /etc/rc.d/init.d/functions 28 | 29 | # Default values 30 | LOCALPORT=6666 31 | DEV= 32 | 33 | SYSLOGADDR= 34 | SYSLOGPORT=514 35 | SYSLOGMACADDR= 36 | 37 | usage () 38 | { 39 | echo $"Usage: $0 {start|stop|status|restart|condrestart}" 1>&2 40 | RETVAL=2 41 | } 42 | 43 | print_address_info () 44 | { 45 | local host=$1 46 | local route via target 47 | 48 | route=$(LANG=C ip -o route get to $host/32) 49 | 50 | [ -z "$DEV" ] && DEV=$(echo $route | sed "s|.* dev \([^ ]*\).*|\1|") 51 | echo "DEV=$DEV" 52 | echo "LOCALADDR=$(echo $route | sed "s|.* src \([^ ]*\).*|\1|")" 53 | if [[ $route == *" via "* ]] ; then 54 | via=$(echo $route | sed "s|.* via \([^ ]*\).*|\1|") 55 | target=$via 56 | else 57 | target=$host 58 | fi 59 | if [ -z "$SYSLOGMACADDR" ]; then 60 | arp=$(LANG=C /sbin/arping -f -c 1 -I $DEV $target 2>/dev/null | awk '/ reply from .*[.*]/ { print gensub(".* reply from .* \\[(.*)\\].*","\\1","G"); exit }') 61 | [ -n "$arp" ] && echo "SYSLOGMACADDR=$arp" 62 | fi 63 | } 64 | 65 | start () 66 | { 67 | [ -f /etc/sysconfig/netconsole ] || exit 6 68 | . /etc/sysconfig/netconsole 69 | 70 | SYSLOGOPTS= 71 | # syslogd server, if any 72 | if [ -n "$SYSLOGADDR" ]; then 73 | # IPv6 regex also covers 4to6, zero-compressed, and link-local addresses with zone-index addresses. 74 | # It should also cover IPv4-embedded, IPv4-mapped, and IPv4-translated IPv6 addresses. 75 | # Taken from: http://stackoverflow.com/a/17871737/3481531 76 | IPv4_regex="^([0-9]{1,3}\.){3}[0-9]{1,3}$" 77 | IPv6_regex="^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$" 78 | if ! [[ "$SYSLOGADDR" =~ $IPv4_regex ]] && ! [[ "$SYSLOGADDR" =~ $IPv6_regex ]]; then 79 | # Use IPv4 by default: 80 | SYSLOGADDR="$(LANG=C getent ahostsv4 $SYSLOGADDR 2> /dev/null)" 81 | 82 | # Try IPv6 in case IPv4 resolution has failed: 83 | if [[ $? -eq 2 ]]; then 84 | SYSLOGADDR="$(LANG=C getent ahostsv6 $SYSLOGADDR 2> /dev/null)" 85 | fi 86 | 87 | if [[ $? -ne 0 ]]; then 88 | echo $"Unable to resolve IP address specified in /etc/sysconfig/netconsole" 1>&2 89 | exit 6 90 | fi 91 | 92 | SYSLOGADDR="$(echo "$SYSLOGADDR" | head -1 | cut --delimiter=' ' --fields=1)" 93 | fi 94 | fi 95 | if [ -z "$SYSLOGADDR" ] ; then 96 | echo $"Server address not specified in /etc/sysconfig/netconsole" 1>&2 97 | exit 6 98 | fi 99 | eval $(print_address_info $SYSLOGADDR) 100 | 101 | if [ -z "$SYSLOGMACADDR" ]; then 102 | echo $"netconsole: can't resolve MAC address of $SYSLOGADDR" 1>&2 103 | exit 1 104 | fi 105 | 106 | SYSLOGOPTS="netconsole=$LOCALPORT@$LOCALADDR/$DEV,$SYSLOGPORT@$SYSLOGADDR/$SYSLOGMACADDR " 107 | 108 | /usr/bin/logger -p daemon.info -t netconsole: inserting netconsole module with arguments \ 109 | $SYSLOGOPTS 110 | if [ -n "$SYSLOGOPTS" ]; then 111 | action $"Initializing netconsole" modprobe netconsole \ 112 | $SYSLOGOPTS 113 | [ "$?" != "0" ] && RETVAL=1 114 | fi 115 | touch /run/lock/subsys/netconsole 116 | } 117 | 118 | stop () 119 | { 120 | if /sbin/lsmod | grep netconsole >/dev/null 2>&1 ; then 121 | action $"Disabling netconsole" rmmod netconsole; 122 | [ "$?" != "0" ] && RETVAL=1 123 | fi 124 | 125 | rm -f /run/lock/subsys/netconsole 126 | } 127 | 128 | status () 129 | { 130 | if /sbin/lsmod | grep netconsole >/dev/null 2>&1 ; then 131 | echo $"netconsole module loaded" 132 | RETVAL=0 133 | else 134 | echo $"netconsole module not loaded" 135 | RETVAL=3 136 | fi 137 | } 138 | 139 | restart () 140 | { 141 | stop 142 | start 143 | } 144 | 145 | condrestart () 146 | { 147 | [ -e /run/lock/subsys/netconsole ] && restart 148 | } 149 | 150 | case "$1" in 151 | stop) stop ;; 152 | status) status ;; 153 | start|restart|reload|force-reload) restart ;; 154 | condrestart) condrestart ;; 155 | *) usage ;; 156 | esac 157 | 158 | exit $RETVAL 159 | -------------------------------------------------------------------------------- /usr/libexec/readonly-root: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Set up readonly-root support. 4 | # 5 | 6 | . /etc/init.d/functions 7 | 8 | # We need to initialize the $HOSTNAME variable by ourselves now: 9 | # (It was previously done for RHEL-6 branch, but got lost in time.) 10 | HOSTNAME="$(hostname)" 11 | 12 | # Check SELinux status 13 | SELINUX_STATE= 14 | if [ -e "/sys/fs/selinux/enforce" ] && [ "$(cat /proc/self/attr/current | tr -d '\000' )" != "kernel" ]; then 15 | if [ -r "/sys/fs/selinux/enforce" ] ; then 16 | SELINUX_STATE=$(cat "/sys/fs/selinux/enforce") 17 | else 18 | # assume enforcing if you can't read it 19 | SELINUX_STATE=1 20 | fi 21 | fi 22 | 23 | selinux_fixup() { 24 | if [ -n "$SELINUX_STATE" ] && [ -e "$1" ]; then 25 | restorecon -R "$1" 26 | fi 27 | } 28 | 29 | # Only read this once. 30 | [ -z "${cmdline}" ] && cmdline=$(cat /proc/cmdline) 31 | 32 | READONLY= 33 | if [ -f /etc/sysconfig/readonly-root ]; then 34 | . /etc/sysconfig/readonly-root 35 | fi 36 | if strstr "$cmdline" readonlyroot ; then 37 | READONLY=yes 38 | [ -z "$RW_MOUNT" ] && RW_MOUNT=/var/lib/stateless/writable 39 | [ -z "$STATE_MOUNT" ] && STATE_MOUNT=/var/lib/stateless/state 40 | fi 41 | if strstr "$cmdline" noreadonlyroot ; then 42 | READONLY=no 43 | fi 44 | 45 | MOUNTS=() 46 | if is_true "$READONLY" || is_true "$TEMPORARY_STATE"; then 47 | 48 | add_mount() { 49 | mnt=${1%/} 50 | MOUNTS=("${MOUNTS[@]}" "$mnt") 51 | } 52 | 53 | cp_empty() { 54 | if [ -e "$1" ]; then 55 | echo "$1" | cpio -p -vd "$RW_MOUNT" &>/dev/null 56 | add_mount $1 57 | fi 58 | } 59 | 60 | cp_dirs() { 61 | if [ -e "$1" ]; then 62 | mkdir -p "$RW_MOUNT$1" 63 | find "$1" -type d -print0 | cpio -p -0vd "$RW_MOUNT" &>/dev/null 64 | add_mount $1 65 | fi 66 | } 67 | 68 | cp_files() { 69 | if [ -e "$1" ]; then 70 | cp -a --parents "$1" "$RW_MOUNT" 71 | add_mount $1 72 | fi 73 | } 74 | 75 | # Common mount options for scratch space regardless of 76 | # type of backing store 77 | mountopts= 78 | 79 | # Scan partitions for local scratch storage 80 | rw_mount_dev=$(blkid -t LABEL="$RW_LABEL" -l -o device) 81 | 82 | bindmountopts= 83 | is_true "$SLAVE_MOUNTS" && bindmountopts="--make-slave" 84 | 85 | # First try to mount scratch storage from /etc/fstab, then any 86 | # partition with the proper label. If either succeeds, be sure 87 | # to wipe the scratch storage clean. If both fail, then mount 88 | # scratch storage via tmpfs. 89 | if mount $mountopts "$RW_MOUNT" > /dev/null 2>&1 ; then 90 | rm -rf "$RW_MOUNT" > /dev/null 2>&1 91 | elif [ x$rw_mount_dev != x ] && mount $rw_mount_dev $mountopts "$RW_MOUNT" > /dev/null 2>&1; then 92 | rm -rf "$RW_MOUNT" > /dev/null 2>&1 93 | else 94 | mount -n -t tmpfs $RW_OPTIONS $mountopts none "$RW_MOUNT" 95 | fi 96 | 97 | for file in /etc/rwtab /etc/rwtab.d/* /run/initramfs/rwtab ; do 98 | is_ignored_file "$file" && continue 99 | [ -f $file ] && while read -r type path ; do 100 | case "$type" in 101 | empty) 102 | cp_empty $path 103 | ;; 104 | files) 105 | cp_files $path 106 | ;; 107 | dirs) 108 | cp_dirs $path 109 | ;; 110 | *) 111 | ;; 112 | esac 113 | done < <(cat $file) 114 | done 115 | 116 | for m in "${MOUNTS[@]}"; do 117 | prefix=0 118 | for mount_point in "${MOUNTS[@]}"; do 119 | [[ $m = $mount_point ]] && continue 120 | if [[ $m =~ ^$mount_point/.* ]] ; then 121 | prefix=1 122 | break 123 | fi 124 | done 125 | [[ $prefix -eq 1 ]] && continue 126 | 127 | mount -n --bind $bindmountopts "$RW_MOUNT$m" "$m" 128 | selinux_fixup "$m" 129 | done 130 | 131 | # Use any state passed by initramfs 132 | [ -d /run/initramfs/state ] && cp -a /run/initramfs/state/* $RW_MOUNT 133 | 134 | # In theory there should be no more than one network interface active 135 | # this early in the boot process -- the one we're booting from. 136 | # Use the network address to set the hostname of the client. This 137 | # must be done even if we have local storage. 138 | ipaddr= 139 | if [ "$HOSTNAME" = "localhost" -o "$HOSTNAME" = "localhost.localdomain" ]; then 140 | ipaddr=$(ip addr show to 0.0.0.0/0 scope global | awk '/[[:space:]]inet / { print gensub("/.*","","g",$2) }') 141 | for ip in $ipaddr ; do 142 | HOSTNAME= 143 | eval $(ipcalc -h $ipaddr 2>/dev/null) 144 | [ -n "$HOSTNAME" ] && { hostname ${HOSTNAME} ; break; } 145 | done 146 | fi 147 | 148 | # Clients with read-only root filesystems may be provided with a 149 | # place where they can place minimal amounts of persistent 150 | # state. SSH keys or puppet certificates for example. 151 | # 152 | # Ideally we'll use puppet to manage the state directory and to 153 | # create the bind mounts. However, until that's all ready this 154 | # is sufficient to build a working system. 155 | 156 | # First try to mount persistent data from /etc/fstab, then any 157 | # partition with the proper label, then fallback to NFS 158 | state_mount_dev=$(blkid -t LABEL="$STATE_LABEL" -l -o device) 159 | if mount $mountopts $STATE_OPTIONS "$STATE_MOUNT" > /dev/null 2>&1 ; then 160 | /bin/true 161 | elif [ x$state_mount_dev != x ] && mount $state_mount_dev $mountopts "$STATE_MOUNT" > /dev/null 2>&1; then 162 | /bin/true 163 | elif [ ! -z "$CLIENTSTATE" ]; then 164 | # No local storage was found. Make a final attempt to find 165 | # state on an NFS server. 166 | 167 | mount -t nfs $CLIENTSTATE/$HOSTNAME $STATE_MOUNT -o rw,nolock 168 | fi 169 | 170 | if [ -w "$STATE_MOUNT" ]; then 171 | 172 | mount_state() { 173 | if [ -e "$1" ]; then 174 | [ ! -e "$STATE_MOUNT$1" ] && cp -a --parents "$1" "$STATE_MOUNT" 175 | mount -n --bind $bindmountopts "$STATE_MOUNT$1" "$1" 176 | fi 177 | } 178 | 179 | for file in /etc/statetab /etc/statetab.d/* ; do 180 | is_ignored_file "$file" && continue 181 | [ ! -f "$file" ] && continue 182 | 183 | if [ -f "$STATE_MOUNT/$file" ] ; then 184 | mount -n --bind $bindmountopts "$STATE_MOUNT/$file" "$file" 185 | fi 186 | 187 | while read -r path ; do 188 | mount_state "$path" 189 | selinux_fixup "$path" 190 | done < <(grep -v "^#" "$file" 2>/dev/null) 191 | done 192 | 193 | if [ -f "$STATE_MOUNT/files" ] ; then 194 | while read -r path ; do 195 | mount_state "$path" 196 | selinux_fixup "$path" 197 | done < <(grep -v "^#" "$STATE_MOUNT/files" 2>/dev/null) 198 | fi 199 | fi 200 | 201 | if mount | grep -q /var/lib/nfs/rpc_pipefs ; then 202 | mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs 203 | fi 204 | fi 205 | -------------------------------------------------------------------------------- /usr/sbin/service: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check whether file $1 is a backup or rpm-generated file and should be ignored 4 | # Copy of the function from etc/rc.d/init.d/functions 5 | is_ignored_file() { 6 | case "$1" in 7 | *~ | *.bak | *.old | *.orig | *.rpmnew | *.rpmorig | *.rpmsave) 8 | return 0 9 | ;; 10 | esac 11 | return 1 12 | } 13 | 14 | VERSION="$(basename $0) ver. 1.1" 15 | USAGE="Usage: $(basename $0) < option > | --status-all | \ 16 | [ service_name [ command | --full-restart ] ]" 17 | SERVICEDIR="/etc/init.d" 18 | ACTIONDIR="/usr/libexec/initscripts/legacy-actions" 19 | SERVICE= 20 | ACTION= 21 | OPTIONS= 22 | 23 | if [ $# -eq 0 ]; then 24 | echo "${USAGE}" >&2 25 | exit 1 26 | fi 27 | 28 | cd / 29 | while [ $# -gt 0 ]; do 30 | case "${1}" in 31 | --help | -h | --h* ) 32 | echo "${USAGE}" >&2 33 | exit 0 34 | ;; 35 | --version | -V ) 36 | echo "${VERSION}" >&2 37 | exit 0 38 | ;; 39 | --ignore-dependencies) 40 | export SYSTEMCTL_IGNORE_DEPENDENCIES=1 41 | shift 42 | ;; 43 | --skip-redirect) 44 | export SYSTEMCTL_SKIP_REDIRECT=1 45 | shift 46 | ;; 47 | *) 48 | if [ -z "${SERVICE}" ] && [ $# -eq 1 ] && [ "${1}" = "--status-all" ]; then 49 | # symlink /etc/init.d -> rc.d/init.d is provided by initscripts package 50 | cd ${SERVICEDIR} || { echo $"Support for initscripts isn't installed" >&2 ; exit 4 ; } 51 | for SERVICE in * ; do 52 | case "${SERVICE}" in 53 | functions | halt | killall | single| linuxconf| kudzu) 54 | ;; 55 | *) 56 | if ! is_ignored_file "${SERVICE}" \ 57 | && [ -x "${SERVICEDIR}/${SERVICE}" ]; then 58 | env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" status 59 | fi 60 | ;; 61 | esac 62 | done 63 | exit 0 64 | elif [ $# -eq 2 ] && [ "${2}" = "--full-restart" ]; then 65 | # symlink /etc/init.d -> rc.d/init.d is provided by initscripts package 66 | [ -L "${SERVICEDIR}" ] || { echo $"Support for initscripts isn't installed" >&2 ; exit 4 ; } 67 | 68 | SERVICE="${1}" 69 | if [ -x "${SERVICEDIR}/${SERVICE}" ]; then 70 | env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" stop 71 | env -i PATH="$PATH" TERM="$TERM" "${SERVICEDIR}/${SERVICE}" start 72 | exit $? 73 | fi 74 | elif [ -z "${SERVICE}" ]; then 75 | SERVICE="${1}" 76 | elif [ -z "${ACTION}" ]; then 77 | ACTION="${1}" 78 | else 79 | OPTIONS="${OPTIONS} ${1}" 80 | fi 81 | shift 82 | ;; 83 | esac 84 | done 85 | 86 | if [ -f "${SERVICEDIR}/${SERVICE}" ]; then 87 | # LSB daemons that dies abnormally in systemd looks alive in systemd's eyes due to RemainAfterExit=yes 88 | # lets reap them before next start 89 | if [ "${ACTION}" = 'start' ] && \ 90 | [ "$(systemctl show -p ActiveState "${SERVICE}".service --value)" = 'active' ] && \ 91 | [ "$(systemctl show -p SubState "${SERVICE}".service --value)" = 'exited' ]; then 92 | /bin/systemctl stop "${SERVICE}".service 93 | fi 94 | 95 | # Workaround to be able to "stop" network.service when it's in inactive state using service instead of systemctl 96 | # Useful for manual testing of network 97 | if [ "${SERVICE}" = 'network' ] && [ "${ACTION}" = 'stop' ] && \ 98 | [ "$(systemctl show -p ActiveState network.service --value)" = 'inactive' ] && \ 99 | [ "$(systemctl show -p SourcePath network.service --value)" = '/etc/rc.d/init.d/network' ]; then 100 | export SYSTEMCTL_SKIP_REDIRECT=1 101 | fi 102 | 103 | env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES="${SYSTEMCTL_IGNORE_DEPENDENCIES}" SYSTEMCTL_SKIP_REDIRECT="${SYSTEMCTL_SKIP_REDIRECT}" "${SERVICEDIR}/${SERVICE}" "${ACTION}" ${OPTIONS} 104 | elif [ -n "${ACTION}" ] && [ -x "${ACTIONDIR}/${SERVICE}/${ACTION}" ]; then 105 | env -i PATH="$PATH" TERM="$TERM" SYSTEMCTL_IGNORE_DEPENDENCIES="${SYSTEMCTL_IGNORE_DEPENDENCIES}" SYSTEMCTL_SKIP_REDIRECT="${SYSTEMCTL_SKIP_REDIRECT}" "${ACTIONDIR}/${SERVICE}/${ACTION}" ${OPTIONS} 106 | elif [[ $ACTION =~ ^(start|stop|restart|try-restart|reload|reload-or-restart|try-reload-or-restart|force-reload|status|condrestart)$ ]]; then 107 | SERVICE_MANGLED=$(/usr/bin/systemd-escape --mangle "${SERVICE}") 108 | echo $"Redirecting to /bin/systemctl ${ACTION} ${SERVICE_MANGLED}${OPTIONS:+ }${OPTIONS}" >&2 109 | exec /bin/systemctl "${ACTION}" "${SERVICE_MANGLED}" ${OPTIONS} 110 | else 111 | echo $"The service command supports only basic LSB actions (start, stop, restart, try-restart, reload, reload-or-restart, try-reload-or-restart, force-reload, status, condrestart). For other actions, please try to use systemctl." >&2 112 | exit 2 113 | fi 114 | --------------------------------------------------------------------------------