-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·85 lines (65 loc) · 2.09 KB
/
setup.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
#!/bin/bash
shopt -s globstar
base_dir="$(dirname "$(realpath -s "$0")")"
firefox_base_dir="/usr/lib64/firefox"
firefox_omni_file="$firefox_base_dir/browser/omni.ja"
firefox_omni_file_backup="${firefox_omni_file}_backup"
firefox_omni_file_zip=$(echo $firefox_omni_file | sed "s|.ja|.zip|g")
firefox_omni_extracted_dir="${firefox_omni_file}_extracted"
function die() {
message=$@
say "\033[1;31mError: $message\033[0m"
exit 255
}
function say() {
message=$@
echo -e "$@"
}
function cleanup() {
rm -rf $firefox_omni_extracted_dir
}
function update_files() {
sub_dir="$1"
target_dir="$2"
item="$3"
for file in "$base_dir/$sub_dir"/**; do
if [[ -f $file ]]; then
file_relative=$(echo $file | sed "s|$base_dir\/$sub_dir\/||g")
if [[ -f $target_dir/$file_relative ]]; then
say "Updating $item: $file_relative"
cp -f $file $target_dir/$file_relative
fi
fi
done
}
function setup_config() {
touch "$firefox_base_dir/browser/defaults/preferences/firefox.js"
update_files "config" "$firefox_base_dir" "config"
}
function setup_omni() {
unzip -q $firefox_omni_file -d $firefox_omni_extracted_dir
update_files "omni" "$firefox_omni_extracted_dir" "OMNI"
cd $firefox_omni_extracted_dir
zip -q -r $firefox_omni_file_zip *
mv $firefox_omni_file_zip $firefox_omni_file
if [[ $SODALITE_FIREFOX_KEEP_OMNI_EXTRACTED == "true" ]]; then
firefox_omni_extracted_dir_backup="${firefox_omni_extracted_dir}_backup"
rm -rf $firefox_omni_extracted_dir_backup
cp -r $firefox_omni_extracted_dir $firefox_omni_extracted_dir_backup
fi
}
if [[ ! $(id -u) = 0 ]]; then
die "Unauthorized (are you root?)"
fi
[[ ! -f /usr/lib/fedora-release ]] && die "Not a Fedora install"
touch /usr/lib/test-file &> /dev/null
[[ ! $? -eq 0 ]] && die "No write permissions to OS (is usroverlay enabled?)"
[[ ! -d $firefox_base_dir ]] && die "Unable to find Firefox installation"
if [[ ! -f $firefox_omni_file_backup ]]; then
say "Creating a backup of OMNI..."
cp $firefox_omni_file $firefox_omni_file_backup
fi
cleanup
setup_config
setup_omni
cleanup