Kir Kolyshkin | 0807ef4 | 2015-02-26 17:11:47 -0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # Copyright (C) 2015, Parallels, 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 as published by |
| 6 | # the Free Software Foundation; either version 2 of the License, or |
| 7 | # (at your option) any later version. |
| 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | # |
| 18 | # |
| 19 | # This script is run in host context right before container start. |
| 20 | # Currently it loads kernel modules that might be needed for a CT. |
| 21 | # |
| 22 | # Parameters are passed in environment variables. |
| 23 | # Required parameters: |
| 24 | # VEID - container ID |
| 25 | |
| 26 | . @PKGCONFDIR@/vz.conf |
| 27 | . @SCRIPTDIR@/vps-functions |
| 28 | |
| 29 | vzcheckvar VEID |
| 30 | |
| 31 | load_modules() { |
| 32 | local mod msg modules |
| 33 | |
WHR | fbb29d4 | 2024-03-30 15:27:11 +0800 | [diff] [blame] | 34 | eval "`. @VPSCONFDIR@/${VEID}.conf && |
| 35 | printf 'DEVNODES=\"%s\";FEATURES=\"%s\"' \"\$DEVNODES\" \"\$FEATURES\"`" |
Kir Kolyshkin | 0807ef4 | 2015-02-26 17:11:47 -0800 | [diff] [blame] | 36 | |
WHR | fbb29d4 | 2024-03-30 15:27:11 +0800 | [diff] [blame] | 37 | if printf %s $DEVNODES | grep -Fq 'net/tun:rw'; then |
Kir Kolyshkin | 0807ef4 | 2015-02-26 17:11:47 -0800 | [diff] [blame] | 38 | modules="$modules tun" |
| 39 | fi |
| 40 | |
WHR | fbb29d4 | 2024-03-30 15:27:11 +0800 | [diff] [blame] | 41 | if printf %s $FEATURES | grep -Fwq 'ppp:on'; then |
Kir Kolyshkin | 0807ef4 | 2015-02-26 17:11:47 -0800 | [diff] [blame] | 42 | modules="$modules ppp_generic" |
| 43 | fi |
| 44 | |
WHR | fbb29d4 | 2024-03-30 15:27:11 +0800 | [diff] [blame] | 45 | if printf %s $FEATURES | grep -Fwq 'bridge:on'; then |
Kir Kolyshkin | 0807ef4 | 2015-02-26 17:11:47 -0800 | [diff] [blame] | 46 | modules="$modules veth bridge" |
| 47 | fi |
| 48 | |
| 49 | for mod in nfs nfsd; do |
WHR | fbb29d4 | 2024-03-30 15:27:11 +0800 | [diff] [blame] | 50 | if printf %s $FEATURES | grep -Fwq "${mod}:on"; then |
Kir Kolyshkin | 0807ef4 | 2015-02-26 17:11:47 -0800 | [diff] [blame] | 51 | modules="$modules $mod" |
| 52 | fi |
| 53 | done |
| 54 | |
| 55 | for mod in ${modules}; do |
| 56 | lsmod | grep -qw $mod && continue |
| 57 | echo "Preloading kernel module: $mod" |
| 58 | msg=$(modprobe $mod >/dev/null 2>&1) || \ |
| 59 | echo "Warning: can't load $mod: $msg" 1>&2 |
| 60 | done |
| 61 | } |
| 62 | |
| 63 | load_modules |
| 64 | |
| 65 | exit 0 |