-
Notifications
You must be signed in to change notification settings - Fork 1
/
cli_createBook.sh
executable file
·53 lines (47 loc) · 1.59 KB
/
cli_createBook.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
#!/bin/bash
# The absolute path to the folder which contains this script
PATHDATA="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
clear
# ? Folder name ?
read -r -p "Type folder name for the book: " folderName
# ? Copy sample content ?
read -r -p "Do you want to create sample content [y/N]? " response
case "$response" in
[yY][eE][sS]|[yY])
sampeContent="YES"
;;
*)
sampeContent="NO"
;;
esac
# Create book folder
if [ ! -d "${folderName}" ]; then
# Directory doesn't exist.
mkdir "${folderName}"
# Copy required scripts / files
cp 00-PanBookMachine-boilerplate/cli_panbookmachine.sh "${folderName}"/
cp 00-PanBookMachine-boilerplate/helper*.sh "${folderName}"/
mkdir "${folderName}"/CONTENT
mkdir "${folderName}"/CONTENT/img
mkdir "${folderName}"/CONFIG
mkdir "${folderName}"/PROCESSED
cp -R 00-PanBookMachine-boilerplate/CONFIG/* "${folderName}"/CONFIG/
mkdir "${folderName}"/CITATIONS
cp -R 00-PanBookMachine-boilerplate/CITATIONS/* "${folderName}"/CITATIONS/
# replace book name with given folder name
sed -i 's/Pan-Book-Machine Manual/'"${folderName}"'/' "${folderName}"/CONFIG/book.conf
mkdir "${folderName}"/misc
cp -R 00-PanBookMachine-boilerplate/misc/* "${folderName}"/misc/
mkdir "${folderName}"/tmp
else
echo
echo "Folder '${folderName}' already exists. Exiting."
exit
fi
# Copy sample content
if [ ${sampeContent} == "YES" ]; then
echo "Copying sample content."
cp -R 00-PanBookMachine-boilerplate/CONTENT/* "${folderName}"/CONTENT/
else
echo "Not copying sample content."
fi