forked from pierrehirel/atomsk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·117 lines (84 loc) · 3.13 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# This script installs Atomsk on the local computer.
# If run with super-user rights (su or sudo), then the
# program and documentation are installed in /usr/local/.
# Otherwise they are installed in the user's home directory.
BINPATH=/usr/local/bin/
DOCPATH=/usr/local/share/doc/
MPATH=/usr/local/share/man/man1/
clear
printf "___________________________________________________________\n"
printf "\e[1m Atomsk Installation Setup\e[0m\n"
printf "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _\n"
if [ ! -e 'atomsk' ] ; then
echo "X!X ERROR: the program 'atomsk' does not exist in current directory."
else
if [ -w ${BINPATH} ] ; then
printf "<?> Atomsk will be installed in ${BINPATH}. Continue? (y/n) "
read answer
if [ "${answer}" = "y" ] ; then
# System configuration file
cp -rf ./etc/atomsk.conf /etc/
# Atomsk binary
chmod +x atomsk
cp atomsk ${BINPATH}
# Atomsk tools
chmod +x ./tools/*.sh
cp ./tools/* ${BINPATH}
echo ">>> The program was successfuly installed in ${BINPATH}"
echo " To run it, enter 'atomsk' in a terminal."
# Atomsk documentation
mkdir -p ${DOCPATH}/atomsk
rm -rf ${DOCPATH}/atomsk/*
cp -rf ./doc/* ${DOCPATH}/atomsk/
chmod -R a+r ${DOCPATH}/atomsk/
echo ">>> The html documentation was installed. You may read it by entering the"
echo " following address in your Web browser: ${DOCPATH}atomsk/index.html"
# Atomsk man page
mkdir -p ${MPATH}
gzip -c ./man/atomsk >${MPATH}/atomsk.1.gz
else
echo ">>> Installation cancelled."
fi
else
# Install program in user's home directory
BINPATH=~/bin/atomsk/
DOCPATH=~/bin/atomsk/doc/
echo "<!> INFO: run this script with super-user rights (su or sudo)"
echo " to install Atomsk system-wide."
echo ""
printf "<?> Atomsk will be installed in ${BINPATH}. Continue? (y/n) "
read answer
if [ "${answer}" = "y" ] ; then
# Create the target folder
mkdir -p ${BINPATH}
# System configuration file
cp -rf ./etc/atomsk.conf ~/.config/
# Atomsk binary
chmod +x atomsk
cp atomsk ${BINPATH}
# Atomsk tools
chmod +x ./tools/*.sh
cp ./tools/* ${BINPATH}
echo ">>> The program was successfuly installed in ${BINPATH}"
echo " To run it, enter 'atomsk' in a terminal."
# Atomsk documentation
mkdir -p ${DOCPATH}
rm -rf ${DOCPATH}/*
cp -rf ./doc/* ${DOCPATH}
chmod -R a+r ${DOCPATH}
echo ">>> The html documentation was installed. You may read it by entering the"
echo " following address in your Web browser: ${DOCPATH}index.html"
# Create alias
n=$(grep "atomsk" ~/.bashrc | wc -l)
if [ $n -eq 0 ] ; then
echo "export PATH=\"\$PATH:${BINPATH}\"" >> ~/.bashrc
source ~/.bashrc
echo ">>> ${BINPATH} was added to your PATH environment variable."
fi
else
echo ">>> Installation cancelled."
fi
fi
fi
printf "___________________________________________________________\n"