Repository navigation
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·123 lines (98 loc) · 3.14 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·123 lines (98 loc) · 3.14 KB
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
121
122
123
#!/usr/bin/env bash
set -eu
BASE_DIR=$(readlink -f ${0%/*})
source ${BASE_DIR}/install_scripts/install.sh
setup_pacman_custom() {
cat <<-EOF > ${PACMAN_TMP}
[options]
CacheDir = ${CACHE_DIR}
Color
CheckSpace
[custom]
SigLevel = Optional TrustAll
Server = file://${CACHE_DIR}
EOF
print_message "Pacman custom configuration setup completed."
}
check_mounted_drive() {
if [[ $(findmnt -M "$MOUNT_POINT") ]]; then
print_success "Drive mounted in $MOUNT_POINT."
else
print_failure "Drive is NOT MOUNTED!"
print_warning "Mount your drive in '$MOUNT_POINT' and re-run this script to install your system."
exit 1
fi
}
prompt_environment()
{
print_message "Your system will be installed using the data in '$ENV_PATH'"
print_warning "Make sure your data is correct before proceeding!"
echo ""
print_trailing "Do you wish to edit '$ENV_PATH'? ((Y)es / (n)o / e(x)it: "
read ans
case $ans in
'n'|'N')
print_success "Ok, installing with settings retrieved from '$ENV_PATH'..."
sleep 1
;;
'x'|'X')
print_failure "Aborting installation!"
exit 1
;;
*)
${EDITOR:-vim} $ENV_PATH
print_message "--------------------------------------------"
print_message "Press ENTER to continue, or Ctrl+C to abort."
print_message "--------------------------------------------"
read
source $ENV_PATH
;;
esac
}
copy_configuration_scripts()
{
local INSTALL_SCRIPTS_TARGET="${MOUNT_POINT}${INSTALL_SCRIPTS_DIR}"
[ -e $INSTALL_SCRIPTS_TARGET ] || mkdir $INSTALL_SCRIPTS_TARGET -v
cp ${BASE_DIR}/install_scripts/* $INSTALL_SCRIPTS_TARGET -v
}
copy_user_scripts() {
local USER_SCRIPTS_TARGET="${MOUNT_POINT}${USER_SCRIPTS_DIR}"
[ -e $USER_SCRIPTS_TARGET ] || mkdir $USER_SCRIPTS_TARGET -v
cp ${BASE_DIR}/user_scripts/* $USER_SCRIPTS_TARGET -v
}
configure_system()
{
copy_configuration_scripts
copy_user_scripts
print_warning ">>> Configuring your system with $DESKTOP_ENV, $BOOTLOADER and $VIDEO_DRIVERS... <<<"
local MNTSHELL="/bin/bash"
if test -f "${MOUNT_POINT}${USERSHELL}"; then
MNTSHELL=$USERSHELL
fi
arch-chroot $MOUNT_POINT $MNTSHELL -c "sh $INSTALL_SCRIPTS_DIR/config.sh && rm $INSTALL_SCRIPTS_DIR $USER_SCRIPTS_DIR -rf"
}
main()
{
# Check pre-install state
check_mounted_drive
# Prompt user to check environment file before installing
prompt_environment
# Setup pacman custom configuration
# [Comment this line if you prefer to use online repositories when installing your system]
setup_pacman_custom
# Install and configure
install_system
configure_system
# Message at end
if [[ $? == 0 ]]; then
print_success "Installation finished! You can reboot now."
else
print_failure "Installation failed! Check errors before trying again."
exit 1
fi
}
# Execute main only if directly run
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
(( EUID == 0 )) || (print_failure 'This script must be run with root privileges' && exit 1)
main $@
fi