/wiki/lib/plugins/revert/lang/el/

ss='main'>index : doc
Systems documentationPunk <punk@tilde.institute>
about summary refs log tree commit diff stats
path: root/core/scripts/setup-install.sh
blob: c1d27653a4605f583ce537076c7bad737f57d188 (plain) (blame)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
#!/bin/bash

# Set Global Vars
ADMIN_USER=c9admin
DEV=$1
CHROOT=$2

# Absolute path to this script,
# e.g. /home/user/c9-doc/core/scripts/foo.sh
SCRIPT=$(readlink -f "$0")
# Absolute path this script is in, 
# e.g. /home/user/c9-doc/core/scripts
SCRIPTPATH=$(dirname "$SCRIPT")
# Absolute path to doc section,
# e.g /home/user/c9-doc/core
DIR=$(dirname "$SCRIPTPATH");
# Absolute path to local data,
# e.g /home/user/local
DIR_LOCAL="$(dirname $(dirname ${DIR}))/local";


DIR_CONF="${DIR}/conf"
DIR_PRT="${DIR}/ports";
ISO_FILE="${DIR_LOCAL}/crux-3.3.iso"

ConfirmOrExit ()
{
    while true
    do
        echo -n "Please confirm (y or n) :"
        read CONFIRM
        case $CONFIRM in
            y|Y|YES|yes|Yes) break ;;
            n|N|no|NO|No)
                echo "Aborting - you entered $CONFIRM"
                exit
                ;;
            *) echo "Please enter only y or n"
        esac
    done
    echo "You entered $CONFIRM. Continuing ..."
}


install_core() {

    echo "1.1.4 Create core.lst and install pkgadd"
    for p in ${CHROOT}mnt/media/crux/core/*; do echo $p >> ${CHROOT}core.lst; done

    tar xf "${CHROOT}mnt/media/crux/core/pkgutils#5.40-1.pkg.tar.xz" usr/bin/pkgadd -O > ${CHROOT}pkgadd

    chmod +x ${CHROOT}pkgadd

    echo "1.1.4 File core.lst complete, review list of packages before continue..."
    read PAUSE
    vim ${CHROOT}core.lst

    echo "1.1.4 Starting install"
    touch ${CHROOT}/var/lib/pkg/db

    cd $CHROOT
    while read line; do
        echo "Installing $line;\n"
        ${CHROOT}pkgadd -u -f -r ${CHROOT} ${line}
    done < ${CHROOT}core.lst

    rm ${CHROOT}pkgadd
    rm ${CHROOT}core.lst

    mkdir ${CHROOT}usr/ports/packages
    cp ${CHROOT}media/crux/core/* ${CHROOT}usr/ports/packages

}

setup_core() {

    echo "1.1.7. dns resolver, copy resolv.conf;\n"
    cp /etc/resolv.conf $CHROOT/etc

    echo "1.1.8. Install Handbook\n"
    cp $CHROOT/media/crux/handbook.txt $CHROOT/root/

    echo "1.1.9. Install Skeletons\n"
    cp -r $DIR_CONF/skel $CHROOT/etc/

    echo "1.2.1. Set hostname and hosts;"
    cp $DIR_CONF/hosts $CHROOT/etc/
    vim $CHROOT/etc/hosts

    echo "1.2.2. Set timezone;"
    chroot $CHROOT /bin/bash -c tzselect

    echo "1.2.3. Set locale;"
    chroot $CHROOT /bin/bash -c "localedef -i en_US -f UTF-8 en_US.UTF-8"
    echo "1.2.4.2. Create Administrator $ADMIN_USER;"

    chroot $CHROOT /usr/bin/env -i \
        HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
        PATH=/bin:/usr/bin:/sbin:/usr/sbin \
        /bin/bash -c "useradd -U -m -k /etc/skel -s /bin/bash $ADMIN_USER"

    echo "1.2.4.3. Add Administrator $ADMIN_USER to wheel group;"
    chroot $CHROOT /bin/bash -c "usermod -a -G wheel $ADMIN_USER"
    echo "1.2.4.3. Uncomment to allow members of group wheel to execute any command\n
    #    %wheel ALL=(ALL) ALL"
    cp $DIR_CONF/sudoers $CHROOT/etc/

    echo "1.2.5. File system table;"
    cp $DIR_CONF/fstab $CHROOT/etc/
    chroot $CHROOT /bin/bash -c "mount >> /etc/fstab"
    vim $CHROOT/etc/fstab

    echo "1.2.6. Initialization Scripts;"
    cp $DIR_CONF/rc.d/* $CHROOT/etc/rc.d/
    cp $DIR_CONF/rc.conf $CHROOT/etc/
    vim $CHROOT/etc/rc.conf

    echo "1.3.1. Build as unprivileged user;"

    chroot $CHROOT /usr/bin/env -i \
        HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
        PATH=/bin:/usr/bin:/sbin:/usr/sbin \
        /bin/bash -c "useradd -U -M -d /usr/ports -s /bin/false pkgmk"

    chroot $CHROOT /usr/bin/env -i \
        HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
        PATH=/bin:/usr/bin:/sbin:/usr/sbin \
        /bin/bash -c "usermod -a -G pkgmk $ADMIN_USER"

    chroot $CHROOT /usr/bin/env -i \
        HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
        PATH=/bin:/usr/bin:/sbin:/usr/sbin \
        /bin/bash -c "chown -R root:pkgmk /usr/ports"

    chroot $CHROOT /usr/bin/env -i \
        HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
        PATH=/bin:/usr/bin:/sbin:/usr/sbin \
        /bin/bash -c "chmod -R 774 /usr/ports"

    chroot $CHROOT /usr/bin/env -i \
        HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
        PATH=/bin:/usr/bin:/sbin:/usr/sbin \
        /bin/bash -c "chmod 775 /usr/ports"

    echo "1.3.2. Ports Layout;"

    chroot --userspec=pkgmk:pkgmk $CHROOT /bin/bash -c "mkdir /usr/ports/work"
    chroot --userspec=pkgmk:pkgmk $CHROOT /bin/bash -c "mkdir /usr/ports/pkgbuild"
    chroot --userspec=pkgmk:pkgmk $CHROOT /bin/bash -c "mkdir /usr/ports/distfiles"

    chroot $CHROOT /usr/bin/env -i \
        HOME=/root TERM="$TERM" PS1='\u:\w\$ ' \
        PATH=/bin:/usr/bin:/sbin:/usr/sbin \
        /bin/bash -c "id pkgmk >> /etc/fstab"

    echo "pkgmk                                           /usr/ports/work tmpfs size=30G,gid=102,uid=101,defaults,mode=0750 0    0" >> $CHROOT/etc/fstab

    vim $CHROOT/etc/fstab

    echo "1.3.3 Configure pkgmk;"
    cp $DIR_CONF/pkgmk.conf $CHROOT/etc/
    #vim $CHROOT/etc/pkgmk.conf

    echo "1.3.4 Configure prt-get;"
    mv $CHROOT/etc/ports/contrib.rsync.inactive $CHROOT/etc/ports/contrib.rsync
    cp $DIR_CONF/prt-get.conf $CHROOT/etc/
    #vim $CHROOT/etc/prt-get.conf
}

install_packages() {

    echo "1.1.5. Install extra packages;"
    cp $CHROOT/media/crux/opt/* $CHROOT/usr/ports/packages
    cp $CHROOT/media/crux/xorg/* $CHROOT/usr/ports/packages

    echo "Installing $CHROOT/usr/ports/packages/fakeroot"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/fakeroot#*
    echo "Installing $CHROOT/usr/ports/packages/dbus"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/dbus#*
    echo "Installing $CHROOT/usr/ports/packages/expat"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/expat#*
    echo "Installing $CHROOT/usr/ports/packages/libnl"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/libnl#*
    echo "Installing $CHROOT/usr/ports/packages/libpng"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/libpng#*
    echo "Installing $CHROOT/usr/ports/packages/freetype"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/freetype#*
    echo "Installing $CHROOT/usr/ports/packages/libffi"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/libffi#*
    echo "Installing $CHROOT/usr/ports/packages/sqlite3"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/sqlite3#*
    echo "Installing $CHROOT/usr/ports/packages/python"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/python#*
    echo "Installing $CHROOT/usr/ports/packages/glib"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/glib#*
    echo "Installing $CHROOT/usr/ports/packages/grub2"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/grub2#*
    echo "Installing $CHROOT/usr/ports/packages/grub2-efi"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/grub2-efi#*
    echo "Installing $CHROOT/usr/ports/packages/wireless-tools"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/wireless-tools#*
    echo "Installing $CHROOT/usr/ports/packages/wpa_supplicant"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/wpa_supplicant#*
    echo "Installing $CHROOT/usr/ports/packages/lvm2"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/lvm2#*
    echo "Installing $CHROOT/usr/ports/packages/mdadm"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/mdadm#*
    echo "Installing $CHROOT/usr/ports/packages/efivar"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/efivar#*
    echo "Installing $CHROOT/usr/ports/packages/efibootmgr"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/efibootmgr#*
    echo "Installing $CHROOT/usr/ports/packages/dosfstools"
    $CHROOT/usr/bin/pkgadd -f -r $CHROOT $CHROOT/usr/ports/packages/dosfstools#*

    echo "1.1.6. Install extra ports;\n"

    mkdir $CHROOT/usr/ports/c9-ports
    cp -r $DIR_PRT/* $CHROOT/usr/ports/c9-ports/

}
echo "SCRIPT=$SCRIPT";
echo "SCRIPTPATH=$SCRIPTPATH";

echo "ADMIN_USER="$ADMIN_USER"\n"
echo "CHROOT=$CHROOT";
echo "DIR=$DIR";
echo "DIR_CONF=$DIR_CONF";
echo "DIR_PRT=$DIR_PRT";

echo "ISO_FILE=$ISO_FILE";
ConfirmOrExit
echo "press enter to continue"
read
install_core
#setup_core
#install_packages

echo "Ready to chroot $CHROOT /bin/bash \n"