1+ #! /usr/bin/env bash
2+ #
3+ # Yamada Hayao
4+ # Twitter: @Hayao0819
5+ # Email : hayao@fascone.net
6+ #
7+ # (c) 2019-2020 Fascode Network.
8+ #
9+
10+ set -e -u
11+
12+
13+ # Default value
14+ # All values can be changed by arguments.
15+ password=alter
16+ boot_splash=false
17+ kernel_config_line=(" zen" " linux-zen" " linux-zen-beaders" " vmlinuz-linux-zen" " linux-zen" )
18+ theme_name=alter-logo
19+ rebuild=false
20+ username=' alter'
21+ os_name=" Alter Linux"
22+ install_dir=" alter"
23+ usershell=" /bin/bash"
24+ debug=false
25+ timezone=" UTC"
26+ localegen=" en_US\\ .UTF-8\\ "
27+ language=" en"
28+
29+
30+ # Parse arguments
31+ while getopts ' p:bt:k:rxu:o:i:s:da:g:z:l:' arg; do
32+ case " ${arg} " in
33+ p) password=" ${OPTARG} " ;;
34+ b) boot_splash=true ;;
35+ t) theme_name=" ${OPTARG} " ;;
36+ k) kernel_config_line=(${OPTARG} ) ;;
37+ r) rebuild=true ;;
38+ u) username=" ${OPTARG} " ;;
39+ o) os_name=" ${OPTARG} " ;;
40+ i) install_dir=" ${OPTARG} " ;;
41+ s) usershell=" ${OPTARG} " ;;
42+ d) debug=true ;;
43+ x) debug=true; set -xv ;;
44+ a) arch=" ${OPTARG} " ;;
45+ g) localegen=" ${OPTARG/ ./ \\ .} \\ " ;;
46+ z) timezone=" ${OPTARG} " ;;
47+ l) language=" ${OPTARG} " ;;
48+ esac
49+ done
50+
51+
52+ # Parse kernel
53+ kernel=" ${kernel_config_line[0]} "
54+ kernel_package=" ${kernel_config_line[1]} "
55+ kernel_headers_packages=" ${kernel_config_line[2]} "
56+ kernel_filename=" ${kernel_config_line[3]} "
57+ kernel_mkinitcpio_profile=" ${kernel_config_line[4]} "
58+
59+
60+ # Delete file only if file exists
61+ # remove <file1> <file2> ...
62+ function remove () {
63+ local _list
64+ local _file
65+ _list=($( echo " $@ " ) )
66+ for _file in " ${_list[@]} " ; do
67+ if [[ -f ${_file} ]]; then
68+ rm -f " ${_file} "
69+ elif [[ -d ${_file} ]]; then
70+ rm -rf " ${_file} "
71+ fi
72+ echo " ${_file} was deleted."
73+ done
74+ }
75+
76+
77+ # Replace wallpaper.
78+ if [[ -f /usr/share/backgrounds/deepin/desktop.jpg ]]; then
79+ remove /usr/share/backgrounds/deepin/desktop.jpg
80+ ln -s /usr/share/backgrounds/alter.png /usr/share/backgrounds/deepin/desktop.jpg
81+ fi
82+ [[ -f /usr/share/backgrounds/alter.png ]] && chmod 644 /usr/share/backgrounds/alter.png
83+
84+
85+ # Bluetooth
86+ rfkill unblock all
87+ systemctl enable bluetooth
88+
89+
90+ # Update system datebase
91+ dconf update
92+
93+ # Added autologin group to auto login
94+ groupadd autologin
95+ usermod -aG autologin ${username}
96+
97+
98+ # Enable LightDM to auto login
99+ if [[ " ${boot_splash} " = true ]]; then
100+ systemctl enable lightdm-plymouth.service
101+ else
102+ systemctl enable lightdm.service
103+ fi
104+
105+ # Added autologin group to auto login
106+ if [[ -z " $( cut -d: -f1 /etc/group | grep -x " autologin" ) " ]]; then
107+ groupadd autologin
108+ fi
109+ usermod -aG autologin ${username}
110+
111+ # ntp
112+ systemctl enable systemd-timesyncd.service
113+
114+ # Replace auto login user
115+ sed -i s/%USERNAME%/${username} /g /etc/lightdm/lightdm.conf
0 commit comments