Skip to content

Commit fe980c9

Browse files
committed
Initial commit
0 parents  commit fe980c9

File tree

7 files changed

+366
-0
lines changed

7 files changed

+366
-0
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Michel Le Bihan
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

deploy_debian_matura

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
. ./functions.sh
4+
5+
BASECOMP=deb10-test
6+
DEBIAN_VERSION="bullseye"
7+
INSTALL_APPS="codeblocks,g++,idle-python3.8,mariadb-server,xterm"
8+
UEFI=true
9+
10+
configure_time
11+
fix_hostname
12+
set_block_devices
13+
14+
restore_ptable || exit 1
15+
create_efi
16+
17+
install_debian
18+
19+
mount $DEVICE /mnt/hd
20+
21+
chroot /mnt/hd useradd -m -s /bin/bash -p $(openssl passwd -1 matura) matura
22+
23+
cp setup/config-mariadb-server-matura.sh /mnt/hd/usr/local/bin/
24+
echo @reboot\ root\ /usr/local/bin/config-mariadb-server-matura.sh\ \&\&\ rm\ /usr/local/bin/config-mariadb-server-matura.sh > /mnt/hd/etc/cron.d/config-mariadb-server-matura
25+
chmod a+x /mnt/hd/etc/cron.d/config-mariadb-server-matura
26+
27+
curl -L https://download.jetbrains.com/python/pycharm-community-2020.1.1.tar.gz | tar zx -C /mnt/hd/opt/
28+
cp setup/jetbrains-pycharm-ce.desktop /mnt/hd/usr/share/applications/
29+
30+
umount /mnt/hd

deploy_windows_matura

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/bin/bash
2+
3+
. ./functions.sh
4+
5+
BASECOMP=win10-test
6+
UEFI=true
7+
8+
9+
for param in $@; do
10+
case $param in
11+
--codeblocks)
12+
INSTALL_APPS="$INSTALL_APPS codeblocks-mingw"
13+
;;
14+
--eclipse)
15+
INSTALL_APPS="$INSTALL_APPS adoptopenjdk-13-jdk eclipse-java"
16+
;;
17+
--idle)
18+
INSTALL_APPS="$INSTALL_APPS python3"
19+
;;
20+
--pycharm)
21+
INSTALL_PYCHARM=true
22+
INSTALL_APPS="$INSTALL_APPS python3"
23+
;;
24+
--visual)
25+
INSTALL_VISUAL_STUDIO=true
26+
;;
27+
--libreoffice)
28+
INSTALL_APPS="$INSTALL_APPS libreoffice"
29+
;;
30+
--full)
31+
INSTALL_APPS="$INSTALL_APPS adoptopenjdk-13-jdk codeblocks-mingw eclipse-java libreoffice python3"
32+
INSTALL_PYCHARM=true
33+
;;
34+
--of13)
35+
INSTALL_OFFICE_2013=true
36+
;;
37+
--of16)
38+
INSTALL_OFFICE_2016=true
39+
;;
40+
--nospell)
41+
INSTALL_APPS="$INSTALL_APPS libreoffice"
42+
DELETE_LIBREOFFICE_DICTS=true
43+
;;
44+
*)
45+
echo unrecognized option $param
46+
exit 1
47+
;;
48+
esac
49+
done
50+
51+
52+
configure_time
53+
fix_hostname
54+
set_block_devices
55+
56+
restore_ptable || exit 1
57+
create_efi
58+
59+
install_windows
60+
61+
win_reg_set_utc_time
62+
63+
mount_win
64+
65+
uninstall_windows_apps
66+
67+
mkdir /mnt/hd/Windows/Panther/
68+
chmod 755 /mnt/hd/Windows/Panther/
69+
cp $IMAGEPATH/obrazy/windows_images/config/Unattend.xml /mnt/hd/Windows/Panther/Unattend.xml || { echo "Error coping Unattend.xml"; exit 1; }
70+
sed -i -e "s/HOSTNAME/$NEWHOSTNAME/" /mnt/hd/Windows/Panther/Unattend.xml
71+
72+
SETUP_SCRIPTS="runonce config-time disable-autologon delete-runners config-local-admin add-matura-user"
73+
for SCRIPT in $SETUP_SCRIPTS; do
74+
cp $IMAGEPATH/setup/$SCRIPT.bat /mnt/hd/$SCRIPT.bat || { echo "Error coping $SCRIPT.bat"; exit 1; }
75+
done
76+
77+
if [ $INSTALL_PYCHARM = true ]; then
78+
cp $IMAGEPATH/setup/install-pycharm.bat /mnt/hd/install-pycharm.bat || { echo "Error coping install-pycharm.bat"; exit 1; }
79+
fi
80+
81+
if [ $INSTALL_VISUAL_STUDIO = true ]; then
82+
cp $IMAGEPATH/setup/install-visual-studio-community-cpp.bat /mnt/hd/install-visual-studio-community-cpp.bat || { echo "Error coping install-visual-studio-community-cpp.bat"; exit 1; }
83+
fi
84+
85+
if [ $INSTALL_OFFICE_2013 = true ]; then
86+
cp $IMAGEPATH/setup/install-office2013.bat /mnt/hd/install-office2013.bat || { echo "Error coping install-office2013.bat"; exit 1; }
87+
fi
88+
89+
if [ $INSTALL_OFFICE_2016 = true ]; then
90+
cp $IMAGEPATH/setup/install-office2016.bat /mnt/hd/install-office2016.bat || { echo "Error coping install-office2016.bat"; exit 1; }
91+
fi
92+
93+
if [ $DELETE_LIBREOFFICE_DICTS = true ]; then
94+
cp $IMAGEPATH/setup/delete-libreoffice-dicts.bat /mnt/hd/delete-libreoffice-dicts.bat || { echo "Error coping delete-libreoffice-dicts.bat"; exit 1; }
95+
fi
96+
97+
echo "SET install_apps=$INSTALL_APPS" > /mnt/hd/just-install.bat || { echo "Error creating just-install.bat"; exit 1; }
98+
cat $IMAGEPATH/setup/just-install.bat >> /mnt/hd/just-install.bat || { echo "Error coping just-install.bat"; exit 1; }
99+
100+
umount_win

functions.sh

+194
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
#!/bin/bash
2+
3+
# Set hostname from DHCP
4+
fix_hostname() {
5+
NEWHOSTNAME=`hostname|sed -e 's/\..*//'`
6+
NEWDOMAIN=`hostname|sed -e 's/[^.]*\.//'`
7+
echo $NEWHOSTNAME > /etc/hostname
8+
}
9+
10+
# Set system time from NTP and hwclock
11+
configure_time() {
12+
echo "Setting time..."
13+
hwclock -s
14+
ntpdate ntp
15+
hwclock -w
16+
}
17+
18+
# Creates EFI partition
19+
create_efi() {
20+
mkfs.fat -F32 $EFI_DEVICE
21+
mount_efi
22+
mkdir -p /mnt/efi/EFI/
23+
umount_efi
24+
}
25+
26+
# Sets default block devices if they are not set
27+
set_block_devices() {
28+
if [ -z $DISK ]; then
29+
DISK=/dev/sda
30+
fi
31+
32+
if [ $UEFI = true ]; then
33+
if [ -z $DEVICE ]; then
34+
DEVICE=${DISK}2
35+
fi
36+
37+
if [ -z $EFI_DEVICE ]; then
38+
EFI_DEVICE=${DISK}1
39+
fi
40+
else
41+
if [ -z $DEVICE ]; then
42+
DEVICE=${DISK}1
43+
fi
44+
fi
45+
}
46+
47+
mount_efi() {
48+
mount $EFI_DEVICE /mnt/efi || { echo "ERROR: mount $DEVICE failed"; exit 5; }
49+
cat /proc/mounts > /etc/mtab
50+
}
51+
52+
umount_efi() {
53+
umount /mnt/efi
54+
cat /proc/mounts > /etc/mtab
55+
}
56+
57+
mount_win() {
58+
mount -o permissions $DEVICE /mnt/hd || { echo "ERROR: mount $DEVICE failed"; exit 5; }
59+
cat /proc/mounts > /etc/mtab
60+
}
61+
62+
umount_win() {
63+
umount /mnt/hd
64+
cat /proc/mounts > /etc/mtab
65+
}
66+
67+
mount_lin() {
68+
69+
mount $DEVICE /mnt/hd
70+
mount -t proc proc /mnt/hd/proc
71+
mount -o bind /dev /mnt/hd/dev/
72+
mount -o bind /sys /mnt/hd/sys/
73+
}
74+
75+
umount_lin() {
76+
umount /mnt/hd/sys
77+
umount /mnt/hd/proc
78+
umount /mnt/hd/dev
79+
umount /mnt/hd
80+
}
81+
82+
win_reg_set_utc_time() {
83+
mount_win
84+
85+
echo -e "cd ControlSet001\\Control\\TimeZoneInformation\nnv 4 RealTimeIsUniversal\ned RealTimeIsUniversal\n1\nq\ny" | chntpw -e /mnt/hd/Windows/System32/config/SYSTEM
86+
87+
umount_win
88+
}
89+
90+
fix_grub2() {
91+
mount_lin
92+
chroot /mnt/hd /usr/sbin/update-grub
93+
if [ $UEFI = true ]; then
94+
mount $EFI_DEVICE /mnt/hd/boot/efi
95+
chroot /mnt/hd /usr/sbin/grub-install --target=x86_64-efi --force $DISK
96+
umount /mnt/hd/boot/efi
97+
else
98+
chroot /mnt/hd /usr/sbin/grub-install --force $DISK
99+
fi
100+
umount_lin
101+
}
102+
103+
# Restore partition table from ptable, ptable.sfdisk or ptable.sgdisk
104+
restore_ptable() {
105+
ROOTDEVICE=$(echo $DISK|sed -e 's/^\([a-z\/]*\).*/\1/')
106+
107+
cd $IMAGEPATH/komputery/$BASECOMP
108+
echo `pwd`
109+
if [ -e ptable ]; then
110+
echo "Taking as ptable: ptable"
111+
dd if=ptable of=$ROOTDEVICE
112+
elif [ -e ptable.sfdisk ]; then
113+
echo "Taking as ptable: ptable.sfdisk"
114+
sfdisk $ROOTDEVICE < ptable.sfdisk
115+
elif [ -e ptable.sgdisk ]; then
116+
echo "Taking as ptable: ptable.sgdisk"
117+
sgdisk --zap-all $ROOTDEVICE
118+
sgdisk --load-backup=ptable.sgdisk $ROOTDEVICE
119+
sgdisk --randomize-guids $ROOTDEVICE
120+
elif [ -e $IMAGEPATH/res/ptable.sfdisk ]; then
121+
echo "Taking as ptable: ptable.sfdisk"
122+
sfdisk $ROOTDEVICE < $IMAGEPATH/res/ptable.sfdisk
123+
else
124+
echo "No valid ptable found!"
125+
exit 2
126+
fi
127+
cd $IMAGEPATH
128+
sync
129+
blockdev --rereadpt $ROOTDEVICE
130+
}
131+
132+
recreate_windows_efi() {
133+
mount_efi
134+
mount_win
135+
136+
mkdir -p /mnt/efi/EFI/Microsoft/Boot/
137+
cp -r /mnt/hd/Windows/Boot/EFI/. /mnt/efi/EFI/Microsoft/Boot/
138+
if [ -f $IMAGEPATH/komputery/$BASECOMP/BCD ]; then
139+
BCD_FILE=$IMAGEPATH/komputery/$BASECOMP/BCD
140+
else
141+
BCD_FILE=$IMAGEPATH/res/BCD
142+
fi
143+
cp $BCD_FILE /mnt/efi/EFI/Microsoft/Boot/BCD
144+
145+
umount_efi
146+
umount_win
147+
}
148+
149+
install_debian() {
150+
if [ $UEFI = true ]; then
151+
GRUB_VARIANT=grub-efi
152+
else
153+
GRUB_VARIANT=grub-pc
154+
fi
155+
156+
mkfs.ext4 -c -FF $DEVICE
157+
mount $DEVICE /mnt/hd
158+
mmdebstrap --include=linux-image-amd64,$GRUB_VARIANT,xserver-xorg-video-all,gnome,gnome-shell-extension-dash-to-panel,libreoffice-gtk3,bash-completion,vim,nano,htop,locales,firefox-esr-l10n-pl,libreoffice-l10n-pl,$INSTALL_APPS --arch amd64 $DEBIAN_VERSION /mnt/hd http://ftp.pl.debian.org/debian/
159+
160+
echo -e "$DEVICE\t/\text4\terrors=remount-ro\t0\t1" > /mnt/hd/etc/fstab
161+
if [ $UEFI = true ]; then
162+
mkdir /mnt/hd/boot/efi/
163+
echo -e "$EFI_DEVICE\t/boot/efi\tvfat\tdefaults\t0\t1" >> /mnt/hd/etc/fstab
164+
fi
165+
166+
echo GRUB_DISABLE_RECOVERY=\"true\" >> /mnt/hd/etc/default/grub
167+
echo sleep-inactive-ac-type=\'blank\' >> /mnt/hd/etc/gdm3/greeter.dconf-defaults
168+
echo -e "[org.gnome.desktop.wm.preferences]\nbutton-layout='appmenu:minimize,maximize,close'\nnum-workspaces=1\n\n[org.gnome.desktop.interface]\nenable-hot-corners=false\n\n[org.gnome.shell]\nfavorite-apps=['firefox-esr.desktop', 'libreoffice-writer.desktop', 'org.gnome.Nautilus.desktop']\nenabled-extensions=['[email protected]', '[email protected]', '[email protected]', '[email protected]']\n\n[org.gnome.shell.extensions.dash-to-panel]\npanel-size=32\nshow-show-apps-button=false\n\n[org.gnome.login-screen]\ndisable-user-list=true\n\n[org.gnome.settings-daemon.plugins.power]\nsleep-inactive-ac-type='nothing'" > /mnt/hd/usr/share/glib-2.0/schemas/00_xivlo.gschema.override
169+
chroot /mnt/hd glib-compile-schemas /usr/share/glib-2.0/schemas/
170+
echo Europe/Warsaw > /mnt/hd/etc/timezone
171+
ln -sf /usr/share/zoneinfo/Europe/Warsaw /mnt/hd/etc/localtime
172+
echo pl_PL\.UTF-8\ UTF-8 >> /mnt/hd/etc/locale.gen
173+
chroot /mnt/hd locale-gen
174+
echo LANG=\"pl_PL.utf8\" > /mnt/hd/etc/default/locale
175+
echo KEYMAP=pl2 > /mnt/hd/etc/vconsole.conf
176+
sed -i -e 's/XKBLAYOUT=.*/XKBLAYOUT=pl/' /mnt/hd/etc/default/keyboard
177+
umount /mnt/hd
178+
179+
fix_grub2
180+
}
181+
182+
install_windows() {
183+
mkfs.ntfs --fast --label Windows $DEVICE
184+
wimapply obrazy/windows_images/Win_Pro_10_2004_64BIT_Polish.wim 5 $DEVICE
185+
recreate_windows_efi
186+
}
187+
188+
uninstall_windows_apps() {
189+
UNINSTALL_APPS="Microsoft.SkypeApp Microsoft.Xbox.TCUI Microsoft.XboxApp Microsoft.XboxGameOverlay Microsoft.XboxGamingOverlay Microsoft.XboxIdentityProvider Microsoft.XboxSpeechToTextOverlay Microsoft.MicrosoftOfficeHub Microsoft.OneConnect Microsoft.Messaging"
190+
191+
for I in $UNINSTALL_APPS; do
192+
rm -r /mnt/hd/Program\ Files/WindowsApps/${I}_*
193+
done
194+
}

komputery/deb10-test/ptable.sfdisk

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
label: gpt
2+
device: /dev/sda
3+
unit: sectors
4+
first-lba: 2048
5+
6+
/dev/sda1 : start= 2048, size= 409600, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B
7+
/dev/sda2 : start= 411648, type=0FC63DAF-8483-4772-8E79-3D69D8477DE4

komputery/win10-test/ptable.sfdisk

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
label: gpt
2+
device: /dev/sda
3+
unit: sectors
4+
first-lba: 2048
5+
6+
/dev/sda1 : start= 2048, size= 409600, type=C12A7328-F81F-11D2-BA4B-00A0C93EC93B
7+
/dev/sda2 : start= 411648, type=EBD0A0A2-B9E5-4433-87C0-68B6B72699C7

setup/config-mariadb-server-matura.sh

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
3+
systemctl start mariadb
4+
5+
echo CREATE\ DATABASE\ matura\; | mysql
6+
echo CREATE\ USER\ matura\@localhost\; | mysql
7+
echo GRANT\ ALL\ PRIVILEGES\ ON\ matura\.\*\ TO\ matura\@localhost\; | mysql

0 commit comments

Comments
 (0)