summaryrefslogtreecommitdiffstats
path: root/templates/enter_dev_container.sh
blob: cd098a6a94a0d5a0afbf2fa4f605c6cef7180eb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash
#	A LinHES development script to start container
#---------
#container_name='linhes_build_root_x86_64'
container_name='linhes_container_root.REPLACE_ARCH.REPLACE_TS'
container_dir=$(pwd)

dev_tools='linhes_dev'
package_build_dir='linhes_pkgbuild'
repo_base_dir='pkg_repo'
repo_base_dir_source='../pkg_repo'

templates="$dev_tools/templates"

#--------



copy_files(){

if [ ! -f $container_name/etc/profile.d/kmdev.sh ]
 then
    echo "  Missing kmdev.sh, copy in setup files"
    cp -f $templates/etc/.bashrc $container_name/root/.bashrc
    cp -f $templates/etc/.bash_profile $container_name/root/

    cp -f $templates/etc/bashrc $container_name/etc/bashrc_linhes
    cp -f $templates/etc/kmdev.sh $container_name/etc/profile.d/

    chmod 0755  $container_name/etc/profile.d/kmdev.sh
    cp -f $templates/container-getty\@.service  $container_name/etc/systemd/system/

    grep -q pts $container_name/etc/securetty
    rc=$?
    if [ ! $rc -eq 0 ]
    then
        for i in `seq 5`
        do
            echo pts\/$i >> $container_name/etc/securetty

        done

    fi



 fi

}

pre_checks(){
    #  must be root:
    if [ $EUID -ne 0 ]
    then
        echo -e "Must be run as the root user" 1>&2
        exit 1
    fi

    # must have the chroot subdirectory:
    if [ ! -d $BROOT ]
    then
        echo $BROOT directory not found
    fi

}


main(){
 pre_checks

 #copy in linhes files
 copy_files


 #Start container
 #check for to see if start it with nspawn or machinectl login

 machinectl list | grep -q $container_name
 rc=$?

if [  $rc -eq 0 ]
then
    echo "Trying machinectl"
    machinectl login $container_name
else
    systemd-nspawn -bD $container_name\
        --bind=$container_dir/$package_build_dir:/data/$package_build_dir \
        --bind=$container_dir/$dev_tools/build_tools:/build_tools \
        --bind=$container_dir/$repo_base_dir_source:/data/$repo_base_dir
fi


}

main