-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall.sh
More file actions
executable file
·140 lines (124 loc) · 3.79 KB
/
Install.sh
File metadata and controls
executable file
·140 lines (124 loc) · 3.79 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#! /bin/bash
# =====================================||===================================== #
# #
# Functions #
# #
# ===============ft_linux==============||==============©Othello=============== #
GetKeyPress()
{
read -rsn 1 input
if [[ "$input" == $'\e' ]]; then
read -rsn 2 -t 0.1 input
input=$'\e'"$input"
fi
}
ClearKeygen()
{
ssh-keygen -f "/home/ohengelm/.ssh/known_hosts" -R "[$ADDRESS]:$PORT";
}
CopyFile()
{
SRC="$1"
DEST="$2"
scp -P $PORT $SRC $USER@$ADDRESS:$DEST
if [ $? -eq 1 ]; then
ClearKeygen;
# ssh-keygen -f "/home/ohengelm/.ssh/known_hosts" -R "[127.0.0.1]:2222";
scp -P $PORT $SRC $USER@$ADDRESS:$DEST
fi
}
RunCmd()
{
Command="$1";
# Dest="$2"
ssh -p $PORT $USER@$ADDRESS -t "$Command"
}
CopyForArchLinux()
{
CopyFile "Utils/*.sh InstallArchLinux/*.sh" \
"/root";
}
CopyForLFS()
{
CopyFile "Utils/*.sh InstallLFS/*.sh eval/*.sh" \
"/root";
}
CopyBLFS()
{
scp -P $PORT ./ConfigureBLFS/*.sh ./Utils/*.sh $USER@$ADDRESS:/root;
}
CopyShman()
{
cp ./Utils/Utils.sh ./shman/Utils.sh;
chmod +x ./shman/shman.sh
scp -P $PORT -r ./shman $USER@$ADDRESS:/usr/src/;
rm ./shman/Utils.sh;
}
CopyEval()
{
scp -P $PORT ./eval/*.sh $USER@$ADDRESS:/eval
}
PORT=2222
USER=root
ADDRESS=127.0.0.1
PASSWD=xxxx
ClearKeygen;
while true; do
Width=$(tput cols);
clear;
printf '%*s\n' "$Width" '' | tr ' ' '-';
echo "Install LFS through SSH";
printf '%*s\n' "$Width" '' | tr ' ' '-';
MachineName="ft_linux"
printf "%-9s %s\n" "Machine:" "$MachineName"
printf "%-9s %s\n" "Image:" "$(VBoxManage showvminfo "$MachineName" | grep ".vdi" | awk -F'"' '{print $2}' | sed -E 's#/Snapshots/.*\.vdi#.vdi#')"
printf "%-9s %s\n" "Checksum:" "$(cat ft_linux_checksum)"
printf '%*s\n' "$Width" '' | tr ' ' '-';
printf "a)\t Install ArchLinux\n"
printf "l)\t Install Linux From Scratch\n"
printf "b)\t Configure Beyond Linux From Scratch\n"
printf "s)\t shman - Shell package Manager\n"
printf "e)\t Evaluation scripts\n"
printf '%*s\n' "$Width" '' | tr ' ' '-';
printf "0)\t Enter as Root\n"
printf "1)\t Enter as arch-chroot (ArchLinux Install)\n"
printf "2)\t Enter as ArchUser\n"
printf "3)\t Enter as Chroot\n"
printf '%*s\n' "$Width" '' | tr ' ' '-';
printf "q)\t exit\n"
printf '%*s\n' "$Width" '' | tr ' ' '-';
echo "lowercase to copy files, UPPERCASE to copy and run files"
printf '%*s\n' "$Width" '' | tr ' ' '-';
if [ ! -z "$ErrorMsg" ]; then
printf "$ErrorMsg\n"
printf '%*s\n' "$Width" '' | tr ' ' '-';
fi
printf "Input: ";
GetKeyPress;
case "$input" in
a) CopyForArchLinux;;
A) CopyForArchLinux;
RunCmd "./InstallArchLinuxRoot.sh";;
l) CopyForLFS;;
L) CopyForLFS;
RunCmd "chmod +x Install*.sh; ./Install.sh";;
b|B) CopyBLFS;;&
B) ssh -p $PORT $USER@$ADDRESS -t "bash --login /root/ConfigureBLFS.sh" || ErrorMsg="$? Failed to enter as Root";;
s|S) CopyShman;;&
S) ssh -p $PORT $USER@$ADDRESS -t "bash --login /usr/src/shman/shman.sh" || ErrorMsg="$? Failed to enter as Root";;
e|E) CopyEval;;&
E) ssh -p $PORT $USER@$ADDRESS -t "cd /eval && bash --login" || ErrorMsg="$? Failed to enter as Root";;
0) ssh -p $PORT $USER@$ADDRESS -t "bash --login" || ErrorMsg="$? Failed to enter as Root";;
1) ssh -p $PORT $USER@$ADDRESS -t "arch-chroot - ArchUser" || ErrorMsg="$? Failed to arch-chroot";;
2) ssh -p $PORT $USER@$ADDRESS -t "su - ArchUser" || ErrorMsg="$? Failed to enter as ArchUser";;
3) ssh -p $PORT $USER@$ADDRESS -t "chroot \"/lfs\" /usr/bin/env -i \
HOME=/root \
TERM=\"$TERM\" \
PS1='(lfs chroot) \u:\w\$ ' \
PATH=/usr/bin:/usr/sbin \
MAKEFLAGS=\"-j$(nproc)\" \
TESTSUITEFLAGS=\"-j$(nproc)\" \
/bin/bash --login" || ErrorMsg="$? Failed to enter as Chroot";;
q) exit;;
esac
done