forked from lyulyul/shine-cluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·72 lines (59 loc) · 1.37 KB
/
install.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
#!/usr/bin/zsh
if [[ -z $1 ]] || [[ ! -d $1 ]]; then
echo "Usage:\n$0 folder" >&2
echo "\nIf the current machine is a compute node, run '$0 compute'." >&2
echo "If the current machine is a login node, run '$0 login'." >&2
exit 1
fi
function loginInstall
{
# checkConnections is guaranteed to exist because it's from this repo.
if grep -E '^session\s+required\s+pam_exec.so\s+stdout\s+/usr/libexec/checkConnections\s+10' /etc/pam.d/sshd > /dev/null; then
echo 'not install checkConnections again.'
else
echo 'session required pam_exec.so stdout /usr/libexec/checkConnections 10' >> /etc/pam.d/sshd
fi
mkdir /etc/daily-tips
}
case $1 in
login)
loginInstall
;;
tatooine)
mkdir /etc/exports.d
;;
esac
foldersToCopy=(etc/systemd etc/security/limits.d)
function needCopy()
{
file=$1
for folder in $foldersToCopy
do
#echo "file=$file, folder=$folder"
if [[ $file = ${folder}* ]]; then
return 0
fi
done
return 1
}
untrackedFiles=$(git status -uall --short --porcelain | awk '$1==''"??"'' {print $2}')
cd $1
for file in **/*(.)
do
bn=$(basename $file)
if [[ install.sh = $bn ]]; then
echo "skip install file"
continue
fi
if (( ${untrackedFiles[(Ie)$file]} )); then
echo "skip untracked file: $file"
continue
fi
if needCopy $file ; then
# echo "copy $file"
cp $PWD/$file /$file
else
# echo "link $file"
ln -s $PWD/$file /$file
fi
done