-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall_dev.sh
More file actions
executable file
·56 lines (45 loc) · 1.37 KB
/
Copy pathinstall_dev.sh
File metadata and controls
executable file
·56 lines (45 loc) · 1.37 KB
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
#!/bin/sh
#
# Installation script for MiceWeb (dev). It copies $bin to one of the directories stored in $binpaths.
miceweb backup >/dev/null
INSTALL_DIR="$(cd "$(dirname "$0")" && pwd)"
bin="$INSTALL_DIR/miceweb"
binpaths="/usr/local/bin /usr/bin"
# This variable contains a nonzero length string in case the script fails
# because of missing write permissions.
is_write_perm_missing=""
cd "$INSTALL_DIR"
branch=$(git symbolic-ref -q --short HEAD)
if [ -n "$branch" ]; then
echo "Installing $branch..." 1>&2
else
echo "You are not currently on a branch, run 'git checkout master' or similar" 1>&2
exit 1
fi
for binpath in $binpaths; do
cp --no-clobber "$binpath/miceweb" "$binpath/miceweb.bak" 2>/dev/null
if cp "$bin" "$binpath/miceweb" ; then
echo "Copied $bin to $binpath" 1>&2
echo "Run 'miceweb' in the terminal" 1>&2
echo "" 1>&2
exit 0
else
if [ -e "$binpath/miceweb" ]; then
echo "Check '$binpath/miceweb', move it to other place and run '$0' again" 1>&2
echo "" 1>&2
exit 1
fi
if [ -d "$binpath" -a ! -w "$binpath" ]; then
is_write_perm_missing=1
fi
fi
done
echo "We cannot install $bin in $binpaths"
if [ -n "$is_write_perm_missing" ]; then
echo "It seems that we do not have the necessary write permissions" 1>&2
echo "Perhaps try running this script as a privileged user:" 1>&2
echo "" 1>&2
echo " sudo $0" 1>&2
echo "" 1>&2
fi
exit 1