Seed code for image-provision
[ta/image-provision.git] / dracut / modules / 00installmedia / module-setup.sh
1 #!/bin/bash
2
3 # Copyright 2019 Nokia
4
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
18 # ex: ts=8 sw=4 sts=4 et filetype=sh
19
20 check() {
21     # do not add this module by default
22     return 255
23 }
24
25 depends ()
26 {
27     echo readcdconf readfloppyconf netconfig
28     return 0
29 }
30
31 installkernel()
32 {
33     instmods = sr_mod mpt3sas raid_class scsi_transport_sas weak-updates/be2iscsi/be2iscsi ipmi_msghandler ipmi_devintf ipmi_si
34 }
35
36 install_python_module() {
37
38     local src dst module
39     if (($# != 3 )); then
40          derror "install_python_module takes 3 arguments"
41     fi
42     src=$1/$3
43     dst=$2/$3
44     module=$3
45     for file in $(find $src -type f -printf "%P\n"); do
46         inst_simple $src/$file $dst/$file
47     done
48 }
49
50 install() {
51     dracut_install df du partprobe parted gunzip ip gzip fdisk find lsmod loadkeys iscsid iscsiadm sync qemu-img sgdisk python ipmitool
52     inst_hook pre-udev 48 "$moddir/load_modules.sh"
53     inst_hook pre-pivot 53 "$moddir/installmedia.sh"
54     inst_simple "$moddir/installmedia-lib.sh" /usr/lib/installmedia-lib.sh
55     cat "$moddir/python_files" | while read dep; do
56         case "$dep" in
57             *.so) inst_library $dep ;;
58             *.py) inst_simple $dep ;;
59             *) inst $dep ;;
60         esac
61     done
62
63     src_dir="/usr/lib/python2.7/site-packages"
64     dst_dir="/usr/lib/python2.7/site-packages"
65     inst_simple $src_dir/__init__.py $dst_dir/__init__.py
66     install_python_module $src_dir $dst_dir "hw_detector"
67 }
68