This repository has been archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathbitwig-fedora.sh
executable file
·209 lines (182 loc) · 6.16 KB
/
bitwig-fedora.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/bash
#=============================================================================
#
# FILE: bitwig-fedora.sh
#
# USAGE: bitwig-fedora.sh [-i|-u] [-h]
#
# DESCRIPTION: This script automates the Bitwig Studio installation process on
# Fedora 28.
# The default starting directory is the current directory.
# Do not descend directories on other filesystems.
#
# OPTIONS: See function - usage - below.
# REQUIREMENTS: Fedora 28 Workstation, Bitwig Studio 2.4
# NOTES: ---
#=============================================================================
ROOT_UID=0
E_NOTROOT=87
VERSION=2.4
DEFAULT_FILENAME="bitwig-studio-$VERSION.deb"
DEFAULT_URL="https://downloads.bitwig.com/stable/$VERSION/$DEFAULT_FILENAME"
INSTALL_LOG="/opt/bitwig-studio/.$DEFAULT_FILENAME.log"
SAFE_FILE_REMOVE="^/\./usr/share/*|^/\./opt/bitwig-studio/*"
SHA256="849c5c74902421f1c901be1d0216be8909d488bbdaeec2f5c56cc8c5b94048d9"
OS_VERSION="Fedora release 28 (Twenty Eight)"
#=== FUNCTION ================================================================
# NAME: usage
# DESCRIPTION: Display usage information for this script.
# PARAMETER 1: Install
#=============================================================================
function usage()
{
printf " usage: $0 <option> \n \n"
printf " options:\n"
printf " -i \t Installs Bitwig Studio\n"
printf " -u \t Uninstall Bitwig Studio\n"
printf " -h \t Show this menu \n"
}
#=== FUNCTION ================================================================
# NAME: download_bitwig
# DESCRIPTION: Download the correct version of Bitwig Studio for the installation.
#=============================================================================
function download_bitwig()
{
if [ -f $DEFAULT_FILENAME ] ; then
echo "Package $DEFAULT_FILENAME already exists."
else
echo "Package $DEFAULT_FILENAME does not exist. Initializing the download."
wget $DEFAULT_URL
fi
echo "Verifying the package checksum. Please wait."
if [ "$(sha256sum $DEFAULT_FILENAME | awk {'print $1'})" != "$SHA256" ] ; then
echo "The checksum doesn't match. Please remove or download the package again."
exit 1
else
echo "Package checksum successfully validated."
fi
}
#=== FUNCTION ================================================================
# NAME: unpack_bitwig
# DESCRIPTION: Unpack deb package. Copy files to the correct folders.
#=============================================================================
function unpack_bitwig()
{
echo "Unpacking $DEFAULT_FILENAME . Please Wait."
tmpfile=$(mktemp)
dpkg-deb -xv $DEFAULT_FILENAME / | grep -v '[/]$' >> $tmpfile
mv $tmpfile $INSTALL_LOG
rm -rf tmpfile
chown 400 $INSTALL_LOG
}
#=== FUNCTION ================================================================
# NAME: install_dependencies
# DESCRIPTION: Install dependencies for the correct execution of this script.
#=============================================================================
function install_dependencies()
{
echo "Installing dependencies. Please Wait."
dnf -y install libbsd bzip2-libs dpkg wget
}
#=== FUNCTION ================================================================
# NAME: create_symbolic_links
# DESCRIPTION: Create symbolic links for library files, to assure the right
# fuction of Bitwig Studio.
#=============================================================================
function create_symbolic_links()
{
echo "Creating symbolic links."
ln -s /usr/lib64/libbz2.so.1 /usr/lib64/libbz2.so.1.0
}
#=== FUNCTION ================================================================
# NAME: check_previous_installation
# DESCRIPTION: Check if Bitwig Studio is already installed on system.
#=============================================================================
function check_previous_installation()
{
if [ -f $INSTALL_LOG ] ; then
echo "Your system already has Bitwig Studio installed."
read -p "Are you sure you want to continue? <y/N> " prompt
if [[ $prompt =~ ^[y]$ ]] ; then
return 0
fi
exit 1
fi
}
#=== FUNCTION ================================================================
# NAME: install
# DESCRIPTION: Set of fuctions to install Bitwig Studio
#=============================================================================
function install()
{
check_previous_installation
install_dependencies
download_bitwig
unpack_bitwig
create_symbolic_links
echo "Installation Complete."
echo "You can execute Bitwig Studio from the Applications menu in gnome"
echo "(Sound and Video section), or running: bitwig-studio in terminal."
}
#=== FUNCTION ================================================================
# NAME: delete_files
# DESCRIPTION: Uninstall Bitwig Studio
#=============================================================================
function delete_files()
{
echo "Deleting Bitwig Studio."
while read file; do
file_to_delete=/$file
# Validation for safety purposes.
if [[ -f $file_to_delete && $file_to_delete =~ $SAFE_FILE_REMOVE ]] ; then
rm -rf $file_to_delete
fi
done < $INSTALL_LOG
rm -rf /opt/bitwig-studio
}
#=== FUNCTION ================================================================
# NAME: uninstall
# DESCRIPTION: Uninstall Bitwig Studio
#=============================================================================
function uninstall()
{
if [ -f $INSTALL_LOG ] ; then
read -p "Are you sure you want to uninstall Bitwig Studio? <y/N> " prompt
if [[ $prompt =~ ^[y]$ ]] ; then
delete_files
echo "Bitwig Studio has been deleted."
fi
else
echo "Could not open the install log file => $INSTALL_LOG"
echo "Are you sure the Bitwig Studio was installed using this script?"
fi
}
#=== MAIN ====================================================================
if [ "$(cat /etc/fedora-release)" != "$OS_VERSION" ] ; then
echo "Wrong OS version. Make sure you run the script in - $OS_VERSION -."
exit 1
fi
if [ "$UID" -ne "$ROOT_UID" ]; then
echo "You must be root to run this script."
exit $E_NOTROOT
fi
if [ $# -eq 0 ] ; then
usage
exit 1
fi
option=$1
case ${option} in
"-h")
usage
;;
"-i")
install
;;
"-u")
uninstall
;;
*)
usage
exit 1
esac
exit 0