-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·112 lines (90 loc) · 2.5 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·112 lines (90 loc) · 2.5 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
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
#!/bin/bash
# Install the Second Life Viewer. This script can install the viewer both
# system-wide and for an individual user.
exec 3>&2 2> /dev/null
if command -v tput > /dev/null ; then
_STYLE_NORMAL="$(tput sgr0)"
_COLOR_RED="$(tput setaf 9)"
fi
exec 2>&3 3>&-
SCRIPTSRC=`readlink -f "$0" || echo "$0"`
RUN_PATH=`dirname "${SCRIPTSRC}" || echo .`
tarball_path=${RUN_PATH}
function prompt()
{
local prompt=$1
local input
echo -n "$prompt"
while read input; do
case $input in
[Yy]* )
return 1
;;
[Nn]* )
return 0
;;
* )
echo "Please enter yes or no."
echo -n "$prompt"
esac
done
}
function die()
{
warn "$1"
exit 1
}
function warn()
{
echo -n "$_COLOR_RED"
echo -e "$1"
echo -n "$_STYLE_NORMAL"
}
function homedir_install()
{
warn "You are not running as a privileged user, so you will only be able"
warn "to install the Second Life Viewer in your home directory. If you"
warn "would like to install the Second Life Viewer system-wide, please run"
warn "this script as the root user, or with the 'sudo' command."
echo
prompt "Proceed with the installation? [Y/N]: "
if [[ $? == 0 ]]; then
exit 0
fi
install_to_prefix "$HOME/.secondlife-install"
$HOME/.secondlife-install/etc/refresh_desktop_app_entry.sh
}
function root_install()
{
local default_prefix="/opt/secondlife-install"
echo -n "Enter the desired installation directory [${default_prefix}]: ";
read
if [[ "$REPLY" = "" ]] ; then
local install_prefix=$default_prefix
else
local install_prefix=$REPLY
fi
install_to_prefix "$install_prefix"
mkdir -p /usr/local/share/applications
${install_prefix}/etc/refresh_desktop_app_entry.sh
}
function install_to_prefix()
{
if [[ -e "$1" && -z $NOBACKUP ]]; then
backup_previous_installation "$1"
fi
mkdir -p "$1" || die "Failed to create installation directory!"
echo " - Installing to $1"
cp -a "${tarball_path}"/* "$1/" || die "Failed to complete the installation!"
}
function backup_previous_installation()
{
local backup_dir="$1".backup-$(date -I)
echo " - Backing up previous installation to $backup_dir"
mv "$1" "$backup_dir" || die "Failed to create backup of existing installation!\nSpecify NOBACKUP=1 when invoking to skip the backup step."
}
if [ "$UID" == "0" ]; then
root_install
else
homedir_install
fi