/
lglive-installer.sh
executable file
·120 lines (103 loc) · 3.49 KB
/
lglive-installer.sh
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
#!/bin/bash
DEVICE=""
select_device() {
while [[ $DEVICE == "" ]]; do
DEVICE=$(zenity --list --title "Select target" --text "Please select the target drive for your live.linuX-gamers installation.
<span color='red'>Warning! All data on the drive will be erased.</span>" --column="Drive" $(ls /dev/sd?))
if [[ $? != 0 ]]; then
exit
elif [[ $DEVICE == "" ]]; then
zenity --info --text "You have to select a target drive or press <b>Cancel</b>."
fi
done
zenity --question --title "Are you sure?" --text "<span color='red' size='x-large'><b>Are you sure?</b> All data on the drive <b>$DEVICE</b> will be deleted.</span>" --cancel-label="Cancel" --ok-label="Yes, erase it."
if [[ $? != 0 ]]; then
exit
fi
echo "Installing to $DEVICE"
}
autopart() {
(
echo "# Creating partition table"
parted -s $DEVICE mklabel msdos
echo "10"
sleep 2
echo "# Creating boot partition"
parted -s $DEVICE mkpart primary 1 100
parted -s $DEVICE set 1 boot on
echo "20"
sleep 2
mkfs.ext2 -L boot-lglive ${DEVICE}1
echo "30"
sleep 2
echo "# Creating swap partition"
parted -s $DEVICE mkpart primary 100 612
echo "40"
sleep 2
mkswap -L swap-lglive ${DEVICE}2
swapon -L swap-lglive
echo "50"
sleep 2
echo "# Creating root partition"
parted -s $DEVICE mkpart primary 612 100%
echo "60"
sleep 2
mkfs.ext4 -L root-lglive ${DEVICE}3
echo "70"
sleep 2
echo "100"
) | zenity --progress --title "Installation" --text="Partitioning" --auto-close --no-cancel --percentage=0
}
copy_files() {
(
echo "# Copying boot partition files"
mkdir /mnt/boot-lglive/
mount -L boot-lglive /mnt/boot-lglive/
echo "10"
cp -a /bootmnt/lglive/boot/* /mnt/boot-lglive/
cp -a /bootmnt/syslinux /mnt/boot-lglive/
echo "20"
echo "# Copying root partition files"
mkdir /mnt/root-lglive/
mount -L root-lglive /mnt/root-lglive/
echo "30"
cp -a /bin /etc /gamelist_* /home /lib /opt /root /run /sbin /srv /usr /var /mnt/root-lglive/
mkdir /mnt/root-lglive/{dev,sys,proc,media,mnt,tmp,boot}
chmod 777 /mnt/root-lglive/tmp/
mount --bind /mnt/root-lglive/tmp /tmp
echo "100"
) | zenity --progress --title "Installation" --text="Copying files" --auto-close --no-cancel --percentage=0
}
install_bootloader() {
(
echo "# Writing master boot record"
cat /usr/lib/syslinux/mbr.bin > $DEVICE
echo "10"
echo "# Installing bootloader"
sed -i 's|/lglive/boot|..|g' /mnt/boot-lglive/syslinux/syslinux.cfg
extlinux --install /mnt/boot-lglive/syslinux
sed -i 's|APPEND initrd|APPEND root=/dev/disk/by-label/root-lglive initrd|g' /mnt/boot-lglive/syslinux/syslinux.cfg
echo "20"
echo "# Baking kernel"
sed -i 's|HOOKS.*|HOOKS="base udev pata scsi sata resume filesystems"|g' /etc/mkinitcpio.conf
sed -i 's|kernel26\.img|lglive.img|g' /etc/mkinitcpio.d/kernel26.preset
sed -i 's|PRESETS.*|PRESETS=("default")|g' /etc/mkinitcpio.d/kernel26.preset
mkdir /boot
mount --bind /mnt/boot-lglive /boot
mkinitcpio -p kernel26
echo "100"
) | zenity --progress --title "Installation" --text="Installing bootloader" --auto-close --no-cancel --percentage=0
}
echo ":: Device selection"
select_device
echo
echo ":: Partitioning device"
autopart
echo
echo ":: Copying files"
copy_files
echo
echo ":: Installing bootloader"
install_bootloader
echo
echo "Done. Really. You may reboot now."