-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprjbld.sh
executable file
·55 lines (44 loc) · 914 Bytes
/
prjbld.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
#!/bin/bash
usage(){
>&2 echo "Usage: $0 <project>"
return 0
}
pname=$1
pdir="./${pname}"
tdir=/var/prjbld/templates
if [ -z "$pname" ]; then
usage
exit 1
elif ! [ -d "$tdir" ]; then
>&2 echo "Unable to find template dir: $tdir"
exit 2
elif [ -d "$pdir" ]; then
>&2 echo "Project dir: $pdir already exsits"
exit 3
fi
# Select template
cur="$PWD"
cd $tdir
echo "Please select a template"
select x in *; do
template="$x"
break
done
# Generate project form template
cd $cur
cp -R ${tdir}/$template $pdir
cd $pdir
for x in *; do
if [ -f "$x" ]; then
new=$(sed "s,PRJNM,$pname,g" <<< "$x")
if [ "$x" = "$new" ]; then
sed "s,PRJNM,$pname,g" < $x > temp
mv -f temp $x
else
sed "s,PRJNM,$pname,g" < $x > $new
if [ -e "$new" ]; then
rm -f $x
fi
fi
fi
done