-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_common.sh
More file actions
37 lines (34 loc) · 839 Bytes
/
setup_common.sh
File metadata and controls
37 lines (34 loc) · 839 Bytes
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
#!/bin/sh
mkdir_if_needed() {
if [ $# -ne 1 ] || [ ! -d $PWD/$1 ]; then
echo "You or I am wrong.." 1>&2
echo "$PWD/$1"
exit 1
fi
if [ ! -d $HOME/$1 ]; then
if mkdir -p $HOME/$1; then
echo "$HOME/$1 is created!"
return 0
else
echo "failed to mkdir -p $HOME/$1 .. "
return 1
fi
fi
return 0
}
sym_to_home() {
if [ $# -ne 1 ] || [ ! -e $PWD/$1 ]; then
echo "file $1 does not exist. exit script .. " 1>&2
exit 1
elif [ -e $HOME/$1 ]; then
echo "$HOME/$1 exists .. kept it .." 1>&2
return 1
fi
if ln -s $PWD/$1 $HOME/$1; then
echo "$HOME/$1 (symlink) is created!"
return 0
else
echo "failed to create symlink $HOME/$1 .. "
return 1
fi
}