blob: 3e80dc791d5549a850479d756e11ccd1b8bfb6e9 [file] [log] [blame] [raw]
Kir Kolyshkin0807ef42015-02-26 17:11:47 -08001#!/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
29vzcheckvar VEID
30
31load_modules() {
32 local mod msg modules
33
WHRfbb29d42024-03-30 15:27:11 +080034 eval "`. @VPSCONFDIR@/${VEID}.conf &&
35 printf 'DEVNODES=\"%s\";FEATURES=\"%s\"' \"\$DEVNODES\" \"\$FEATURES\"`"
Kir Kolyshkin0807ef42015-02-26 17:11:47 -080036
WHRfbb29d42024-03-30 15:27:11 +080037 if printf %s $DEVNODES | grep -Fq 'net/tun:rw'; then
Kir Kolyshkin0807ef42015-02-26 17:11:47 -080038 modules="$modules tun"
39 fi
40
WHRfbb29d42024-03-30 15:27:11 +080041 if printf %s $FEATURES | grep -Fwq 'ppp:on'; then
Kir Kolyshkin0807ef42015-02-26 17:11:47 -080042 modules="$modules ppp_generic"
43 fi
44
WHRfbb29d42024-03-30 15:27:11 +080045 if printf %s $FEATURES | grep -Fwq 'bridge:on'; then
Kir Kolyshkin0807ef42015-02-26 17:11:47 -080046 modules="$modules veth bridge"
47 fi
48
49 for mod in nfs nfsd; do
WHRfbb29d42024-03-30 15:27:11 +080050 if printf %s $FEATURES | grep -Fwq "${mod}:on"; then
Kir Kolyshkin0807ef42015-02-26 17:11:47 -080051 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
63load_modules
64
65exit 0