OSDN Git Service

fix quotes
[instantos/instantARCH.git] / installutils.sh
1 #!/bin/bash
2
3 # functions used for the actual installation
4
5 # reset working dir
6 rcd() {
7     cd /root/instantARCH
8 }
9
10 # this gets executed if a module fails
11 # it marks the installation as failed
12 serror() {
13     # touching noerror skips error checking for one check
14     if [ -e /opt/noerror ]; then
15         echo "skipping error"
16         rm /opt/noerror
17     else
18         # indicator file
19         touch /opt/installfailed
20         echo "script failed"
21         exit 1
22     fi
23 }
24
25 # this sets the status message
26 # displayed at the bottom of the screen when using the GUI installer
27 setinfo() {
28     if [ -e /usr/share/liveutils ]; then
29         pkill instantmenu
30     fi
31     echo "$@" >/opt/instantprogress
32     echo "$@"
33 }
34
35 # run a script inside the installation medium
36 escript() {
37     setinfo "${2:-info}"
38     rcd
39     ./$1.sh || serror
40     echo "$1" >>/tmp/instantprogress
41 }
42
43 # scripts executed in installed environment
44 chrootscript() {
45     setinfo "${2:-info}"
46     if ! mount | grep -q '/mnt'; then
47         echo "mount failed"
48         exit 1
49     fi
50
51     rcd
52
53     if command -v arch-chroot; then
54         arch-chroot /mnt "/root/instantARCH/${1}.sh" || serror
55     elif command -v manjaro-chroot; then
56         manjaro-chroot /mnt "/root/instantARCH/${1}.sh" || serror
57     else
58         artools-chroot /mnt "/root/instantARCH/${1}.sh" || serror
59     fi
60
61     echo "chroot: $1" >>/tmp/instantprogress
62
63 }