improvements
[automated-distro-installer] / mymk-basefile
1 #!/bin/bash
2 # This file is part of Ian Kelling's automated-distro-installer
3 # Copyright (C) 2024 Ian Kelling
4
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
14
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
19 set -e; . /usr/local/lib/bash-bear; set +e
20
21 this_file="$(readlink -f -- "${BASH_SOURCE[0]}")"
22 readonly this_file this_dir="${this_file%/*}"
23 cd "$this_dir"
24
25 usage() {
26 cat <<'EOF'
27 Usage: mymk-basefile [-h|--help] [mk-basefile_args]
28 Wrap fai's mk-basefile so output dir is $BASEFILE_DIR if it exists.
29
30 And fix things for trisquel. mk-basefile has a trisquel mirror added.
31
32 fai-project maintains ubuntu and debian basefiles, but it doesn't update
33 them often. Better to build our all our own.
34
35
36 Args I've used before:
37
38 -z BOOKWORM64
39 -z BULLSEYE64
40 -z BUSTER64
41 -z STRETCH64
42 -z XENIAL64
43
44 -z ECNE64
45 -z ARAMO64
46 -z NABIA64
47 -z ETIONA64
48 -z FLIDAS64
49 -z BELENOS64
50
51 -h|--help Print help and exit.
52
53 Note: Uses GNU getopt options parsing style.
54
55 Usage of mk-basefile:
56
57 EOF
58 $this_dir/fai/config/basefiles/mk-basefile -h
59 exit 0
60 }
61
62 case $1 in
63 -h|--help)
64 usage
65 ;;
66 esac
67
68 if [[ $EUID != 0 ]]; then
69 s=sudo
70 fi
71
72 cd /usr/share/debootstrap/scripts
73 for d in belenos flidas; do
74 if [[ ! -L $d && ! -e $d ]]; then
75 $s ln -sf gutsy $d;
76 fi
77 done
78 d=etiona
79 if [[ ! -L $d && ! -e $d ]]; then
80 $s ln -sf trisquel etiona;
81 fi
82
83 if [[ $BASEFILE_DIR ]]; then
84 cd $BASEFILE_DIR
85 fi
86
87 if awk '$2 == "/tmp" && $4 ~ /nodev/' /proc/mounts | grep -q . || [[ $? == 141 ]]; then
88 $s mount -o remount,dev /tmp
89 fi
90 $s $this_dir/fai/config/basefiles/mk-basefile "$@"