-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit_project.sh
More file actions
84 lines (63 loc) · 1.35 KB
/
init_project.sh
File metadata and controls
84 lines (63 loc) · 1.35 KB
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
#!/bin/bash
# tackle two things
# 1. replace four variables. icp {AUTHOR} {PORT} COMPANY in all files
# 2. company dir's name change to COMPANY , project dir's name change to icp
COMPANY=$1
PROJECT=$2
AUTHOR=$3
PORT=$4
init()
{
echo "current working directory is : "
pwd
echo "now it is: "
date
echo "welcome to easnynode!"
}
init
readin()
{
echo "Please input company'name:"
read COMPANY
COMPANY="$(echo $COMPANY | tr '[:upper:]' '[:lower:]')"
echo "Please input project'name:"
read PROJECT
PROJECT="$(echo $PROJECT | tr '[:upper:]' '[:lower:]')"
echo "Please input http server's port:"
read PORT
echo "Please input author's name:"
read AUTHOR
}
readin
replacedir()
{
if test -e $PWD/src/company/project
then
mv src/company/project src/company/$PROJECT
if test -d $PWD/src/company
then
mv src/company/ src/$COMPANY
else
echo $PWD/src/company not exist
fi
else
echo $PWD/src/company/project not exist
fi
}
replacedir
replace()
{
sed -i '' -e s/{PROJECT}/$PROJECT/g `grep {PROJECT} -rl .`
sed -i '' -e s/{COMPANY}/$COMPANY/g `grep {COMPANY} -rl .`
sed -i '' -e s/{AUTHOR}/$AUTHOR/g `grep {AUTHOR} -rl .`
sed -i '' -e s/{PORT}/$PORT/g `grep {PORT} -rl .`
}
replace
print()
{
echo 'Company:' $COMPANY
echo 'Project:' $PROJECT
echo 'AUTHOR:' $AUTHOR
echo 'PORT:' $PORT
}
print