forked from mattwind/alfs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
useradd_lfs.sh
executable file
·78 lines (60 loc) · 1.27 KB
/
useradd_lfs.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
#!/bin/bash
# new lfs user pwd set to lfs
if [ "$EUID" -ne 0 ]
then echo "Please run as root"
exit
fi
if mount | grep /mnt/lfs > /dev/null; then
echo
echo "LFS mount found."
echo
else
echo
echo "No LFS partition found at /mnt/lfs."
echo
echo "Check out README.md"
echo
exit
fi
MAKEFLAGS=-j`nproc`
# Create LFS folders
# Set permissions
mkdir -pv $LFS/tools
chmod -v a+wt $LFS/sources
mkdir -pv $LFS/{bin,etc,lib,sbin,usr,var}
case $(uname -m) in
x86_64) mkdir -pv $LFS/lib64 ;;
esac
# Create lfs users
groupadd lfs
useradd -s /bin/bash -g lfs -m -k /dev/null lfs
echo
echo "Please set the lfs user password"
echo
echo 'lfs:lfs' | sudo chpasswd
chown -v lfs $LFS/{usr,lib,var,etc,bin,sbin,tools,alfs}
case $(uname -m) in
x86_64) chown -v lfs $LFS/lib64 ;;
esac
chown -v lfs $LFS/sources
cat > /home/lfs/.bash_profile << "EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
EOF
cat > /home/lfs/.bashrc << "EOF"
set +h
umask 022
MAKEFLAGS=-j`nproc`
LFS=/mnt/lfs
ALFS=/mnt/lfs/alfs
LC_ALL=POSIX
LFS_TGT=$(uname -m)-lfs-linux-gnu
PATH=/usr/bin
if [ ! -L /bin ]; then PATH=/bin:$PATH; fi
PATH=$LFS/tools/bin:$PATH
export ALFS LFS LC_ALL LFS_TGT PATH MAKEFLAGS
EOF
chown lfs:lfs /home/lfs/.bash_profile
chown lfs:lfs /home/lfs/.bashrc
echo
echo "Done"
echo