-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathconfigureSmallDistro.sh
executable file
·119 lines (90 loc) · 2.67 KB
/
configureSmallDistro.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
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
#!/usr/bin/env bash
# This script should only be runned once.
fileSystemPath='./smallFileSystem';
echo '
# Created by ./configureAlpine.sh
echo -e "nameserver 1.1.1.1\nnameserver 1.0.0.1" > /etc/resolv.conf
rm /etc/profile.d/setup.sh
' > ./"$fileSystemPath"/etc/profile.d/setup.sh
echo '
# ENV
for i in `env | sed '"'"'s/=.*//'"'"'` ; do
unset $i
done
export HOME="/home"
export SHELL=/bin/sh
export PATH="";
export USER=root
export PAGER=less
export CHARSET=UTF-8
export LANG=C.UTF-8
export TERM=xterm-256color
export EDITOR=vi
export LC_COLLATE=C
export _=/usr/bin/env
addPath() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="${PATH:+"$PATH:"}$1";
fi
}
addPath /home/.local/bin
addPath "/usr/local/sbin"
addPath "/usr/local/bin"
addPath "/usr/sbin"
addPath "/usr/bin"
addPath "/sbin"
addPath "/bin"
unset -f addPath
yellow=$'"'"'\e[1;33m'"'"';
green=$'"'"'\e[1;32m'"'"';
reset=$'"'"'\e[0m'"'"';
PS1='"'"'\n\n${yellow}SMALL${green} $(pwd)${reset}\n> '"'"';
PS2='"'"'${yellow}.${reset} '"'"';
# ENV #
# MISC
which bash > /dev/null &&
shopt -s checkwinsize \
shopt -s cdable_vars \
shopt -s autocd \
shopt -s histappend;
export PROMPT_COMMAND='"'"'history -a'"'"';
export HISTSIZE=10000;
export HISTFILESIZE=20000;
alias ls='"'"'ls --color=auto'"'"';
alias dir='"'"'dir --color=auto'"'"';
alias vdir='"'"'vdir --color=auto'"'"';
alias grep='"'"'grep --color=auto'"'"';
alias fgrep='"'"'fgrep --color=auto'"'"';
alias egrep='"'"'egrep --color=auto'"'"';
alias l='"'"'ls'"'"';
alias la='"'"'ls -a'"'"';
alias v='"'"'vi'"'"';
alias c='"'"'clear'"'"';
alias cl='"'"'clear && ls'"'"';
alias ..='"'"'cd ..'"'"';
alias ...='"'"'cd ../..'"'"';
alias ....='"'"'cd ../../..'"'"';
alias .....='"'"'cd ../../../..'"'"';
alias pserv='"'"'python -m http.server'"'"';
alias gitc='"'"'git clone'"'"';
alias 775='"'"'chmod +775'"'"';
alias h='"'"'history'"'"';
alias q='"'"'exit'"'"';
if [ ! -f "/tmp/.small_command_1" ]; then
clear
cat /etc/motd
fi
' > ./"$fileSystemPath"/etc/profile.d/persistent.sh
echo -e '\e[1;33m' > ./"$fileSystemPath"/etc/motd;
echo '
##### # # # # #
# # ## ## # # # #
# # # # # # # # #
##### # # # # # # #
# # # ####### # #
# # # # # # # #
##### # # # # ####### #######
' >> ./"$fileSystemPath"/etc/motd
echo -e '\e[0m' >> ./"$fileSystemPath"/etc/motd;
# ./proot -0 -r ./alpineFileSystem -w /root --kill-on-exit /bin/sh /home/config.sh
echo "DONE."