-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·81 lines (62 loc) · 2.36 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
#!/usr/bin/env bash
replace_string() {
placeholder=$1
new_string=$2
file_name=$3
ESCAPED_REPLACE=$(printf '%s\n' "$new_string" | sed -e 's/[\/&]/\\&/g')
sed -i '' -e "s/$placeholder/$ESCAPED_REPLACE/" "$file_name"
}
artifact_link="https://www.dropbox.com/s/96wirqrwvw8qefs/expose-to-the-light_2.13-0.1.22.jar?dl=1"
ettl_link="https://www.dropbox.com/s/gbqwbobbwvtnv12/ettl?dl=1"
artifact="expose-to-the-light_2.13-0.1.22.jar"
echo "Creating app folder at /usr/local/opt/ettl"
sudo mkdir -p /usr/local/opt/ettl
sudo chown -R pi /usr/local/opt/ettl
cd /usr/local/opt/ettl
echo "Downloading artifact to /usr/local/opt/ettl..."
curl -L -o "$artifact" "$artifact_link"
echo "Downloading ettl script to /usr/local/opt/ettl..."
curl -L -o "ettl" "$ettl_link"
sudo chmod u+x ettl
echo "Artifact's Manifest file:"
jar xf "$artifact" META-INF/MANIFEST.MF && cat META-INF/MANIFEST.MF
echo "Installing and adding to PATH..."
# make the artifact path absolute
replace_string "artif=.*" "artif=\"/usr/local/opt/ettl/$artifact\"" "ettl"
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
echo "Detected OS is Linux"
echo "Updating apt"
sudo apt-get -y update
echo "Installing ettl command to /usr/local/bin"
cd /usr/local/bin
sudo ln -fs /usr/local/opt/ettl/ettl ettl
sudo chown -R pi /usr/local/bin/ettl
echo "Installing dependencies"
if ! command -v java $> /dev/null
then
echo "java is missing, therefore installing java 11"
sudo apt-get -y install openjdk-11-jdk
fi
if ! command -v gphoto2 $> /dev/null
then
echo "gphoto2 is missing, therefore installing gphoto2"
# https://github.com/gonzalo/gphoto2-updater
# sudo wget https://raw.githubusercontent.com/gonzalo/gphoto2-updater/master/gphoto2-updater.sh && chmod +x gphoto2-updater.sh && sudo ./gphoto2-updater.sh
sudo apt -y install gphoto2
sudo apt -y install libgphoto2-6
fi
source ~/.bashrc
elif [[ "$OSTYPE" == "darwin"* ]]; then
echo "Detected OS is macOS"
echo "Installing application to /usr/local/opt/ettl"
replace_string "vm_options=.*" "vm_options=\"-Djna.library.path=/usr/local/Cellar/libgphoto2/2.5.27/lib\"" "ettl"
echo "Installing ettl command to /usr/local/bin"
cd /usr/local/bin
sudo ln -fs /usr/local/opt/ettl/ettl ettl
echo "Installing dependencies"
brew install gphoto2
brew install libgphoto2
source "$ZSH"/oh-my-zsh.sh
else
echo "big problemo! No OSTYPE"
fi