-
Notifications
You must be signed in to change notification settings - Fork 52
/
officeonline-install.sh
executable file
·179 lines (169 loc) · 7.2 KB
/
officeonline-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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/bin/bash
#VERSION 2.5.2
#Written by: Subhi H. & Marc C.
#Github Contributors: Aalaesar, Kassiematis, morph027
#This script is free software: you can redistribute it and/or modify it under
#the terms of the GNU General Public License as published by the Free Software
#Foundation, either version 3 of the License, or (at your option) any later version.
#This script is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
#or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
#You should have received a copy of the GNU General Public License along with
#this program. If not, see http://www.gnu.org/licenses/.
# shellcheck disable=SC2034,SC2154
whendiditstopped() {
echo "Ended at $(date +'%Y-%m-%d %H:%M:%S')" >> ${log_dir}/timewatch.log
}
if [[ $(id -u) -ne 0 ]] ; then echo 'Please run me as root or "sudo ./officeonline-install.sh"' ; exit 1 ; fi
ScriptFullPath="$(dirname "$(realpath $0)")"
# shellcheck source=/project/lib/checksys.sh
# shellcheck source=/project/lib/helpmenu.sh
# shellcheck source=/project/lib/SearchInGit.sh
# shellcheck source=/project/lib/security.sh
for mylibrary in $ScriptFullPath/lib/*.sh; do
source "$mylibrary"
done
# fix for system coming without curl pre-installed
if [ -z "$(for subpath in $(echo $PATH|tr ':' ' '); do ls $subpath/curl 2>/dev/null; done)" ]; then
apt-get install curl -y
fi
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-c|--config)
if [[ -f $2 ]]; then
# shellcheck source=/project/officeonline-install.cfg
opt_config_file="$2"
elif [[ "$2" =~ .*'='.* ]]; then
# override ONE variable at a time
# can be repeated
# test if it is a variable with an = in it.
opt_config_vars="$opt_config_vars $2"
fi
# else skip the parameter
shift ;;
-f|--force)
# quick option to force build from command line
# this option can be repeated
case $2 in
oo|lo|core|libreoffice|libre-office) opt_config_vars="$opt_config_vars lo_forcebuild=true" ;;
cool|online|coolwd|collabora) opt_config_vars="$opt_config_vars cool_forcebuild=true" ;;
poco) opt_config_vars="$opt_config_vars poco_forcebuild=true" ;;
esac
;;
-h|--help)
help_menu
exit
;;
-l|--libreoffice_commit)
opt_lo_src_commit="$2"
shift # past argument
;;
-o|--libreoffice_online_commit)
opt_cool_src_commit="$2"
shift # past argument
;;
-p|--poco_version)
opt_poco_version="$2"
shift # past argument
;;
#--default)
#DEFAULT=YES
#;;
*)
# unknown option
;;
esac
shift # past argument or value
done
# shellcheck source=/project/lib/default.cfg
source "$ScriptFullPath/lib/default.cfg"
if [ -n "$opt_config_file" ]; then
# shellcheck source=/project/officeonline-install.cfg
source "$opt_config_file"
elif [ "$ScriptFullPath" != "$PWD" ] && [ -s "$PWD/officeonline-install.cfg" ]; then
# shellcheck source=/project/officeonline-install.cfg
source "$PWD/officeonline-install.cfg"
elif [ -s "$HOME/officeonline-install.cfg" ]; then
# shellcheck source=/project/officeonline-install.cfg
source "$HOME/officeonline-install.cfg"
elif [ -s "/etc/coolwsd/officeonline-install.cfg" ]; then
# shellcheck source=/project/officeonline-install.cfg
source "/etc/coolwsd/officeonline-install.cfg"
elif [ -s "$ScriptFullPath/officeonline-install.cfg" ]; then
# shellcheck source=/project/officeonline-install.cfg
source "$ScriptFullPath/officeonline-install.cfg"
fi
# backward compatibility block :
[ -n "$opt_lo_src_commit" ] && lo_src_commit="$opt_lo_src_commit"
[ -n "$opt_cool_src_commit" ] && cool_src_commit="$opt_cool_src_commit"
[ -n "$opt_poco_version" ] && poco_version="$opt_poco_version"
# override using all variables given using the -c option
if [ -n "$opt_config_vars" ]; then
for my_var in $opt_config_vars; do
eval "$my_var"
done
fi
if ${sh_interactive:?}; then clear; fi
###############################################################################
################################# OPERATIONS ##################################
###############################################################################
#clear the logs in case of super multi fast script run.
[ "${log_dir:?}" = '/' ] && exit 100 # just to be safe
[ -f ${log_dir} ] && rm -rf ${log_dir}
mkdir -p ${log_dir}
touch ${log_dir}/preparation.log
touch ${log_dir}/LO-compilation.log
touch ${log_dir}/POCO-compilation.log
touch ${log_dir}/cool-compilation.log
###Added timewatch log file just to now when the script start and stop.
echo "Started at $(date +'%Y-%m-%d %H:%M:%S')" > ${log_dir}/timewatch.log
trap whendiditstopped EXIT
{
# shellcheck source=/project/bin/systemChecks.sh
source "$ScriptFullPath/bin/systemChecks.sh"
# shellcheck source=/project/bin/systemSetup.sh
source "$ScriptFullPath/bin/systemSetup.sh"
} > >(tee -a ${log_dir}/preparation.log) 2> >(tee -a ${log_dir}/preparation.log >&2)
###############################################################################
######################## libreoffice compilation ##############################
{
# shellcheck source=/project/bin/corePrep.sh
source "$ScriptFullPath/bin/corePrep.sh"
} > >(tee -a ${log_dir}/LO-compilation.log) 2> >(tee -a ${log_dir}/LO-compilation.log >&2)
# shellcheck source=/project/bin/coreBuild.sh
source "$ScriptFullPath/bin/coreBuild.sh"
###############################################################################
############################# Poco Installation ###############################
{
# shellcheck source=/project/bin/pocoPrep.sh
source "$ScriptFullPath/bin/pocoPrep.sh"
# shellcheck source=/project/bin/pocoBuild.sh
source "$ScriptFullPath/bin/pocoBuild.sh"
} > >(tee -a ${log_dir}/POCO-compilation.log) 2> >(tee -a ${log_dir}/POCO-compilation.log >&2)
###############################################################################
########################### coolwsd Installation ##############################
{
# shellcheck source=/project/bin/onlinePrep.sh
source "$ScriptFullPath/bin/onlinePrep.sh"
# shellcheck source=/project/bin/onlineBuild.sh
source "$ScriptFullPath/bin/onlineBuild.sh"
# shellcheck source=/project/bin/onlineInstall.sh
source "$ScriptFullPath/bin/onlineInstall.sh"
} > >(tee -a ${log_dir}/cool-compilation.log) 2> >(tee -a ${log_dir}/cool-compilation.log >&2)
### Testing coolwsd ###
if ${sh_interactive}; then
admin_pwd=$(awk -F'password=' '{printf $2}' /lib/systemd/system/${coolwsd_service_name}.service )
dialog --backtitle "Information" \
--title "Note" \
--msgbox "The installation logs are in ${log_dir}. After reboot you can use $coolwsd_service_name.service using: systemctl (start,stop or status) $coolwsd_service_name.service.\\n
Your user is admin and password is $admin_pwd. Please change your user and/or password in (/lib/systemd/system/$coolwsd_service_name.service),\\n
after that run (systemctl daemon-reload && systemctl restart $coolwsd_service_name.service).\\nPlease press OK and wait 15 sec. I will start the service." 10 145
clear
fi
{
# shellcheck source=/project/bin/onlineTests.sh
source "$ScriptFullPath/bin/onlineTests.sh"
} > >(tee -a ${log_dir}/cool-compilation.log) 2> >(tee -a ${log_dir}/cool-compilation.log >&2)
exit 0