-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·51 lines (39 loc) · 1.25 KB
/
install.sh
File metadata and controls
executable file
·51 lines (39 loc) · 1.25 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
#!/bin/bash
# Copyright (c) 2015 Marcus Downing <marcus.downing@gmail.com>
# Released under the 2-clause BSD license.
# http://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac
function abspath {
if readlink -f "$1" 2>&1 | grep -q 'readlink: illegal option -- f'; then
TARGET_FILE="$1"
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
# Iterate down a (possible) chain of symlinks
while [ -L "$TARGET_FILE" ]
do
TARGET_FILE=`readlink $TARGET_FILE`
cd `dirname $TARGET_FILE`
TARGET_FILE=`basename $TARGET_FILE`
done
# Compute the canonicalized name by finding the physical path
# for the directory we're in and appending the target file.
PHYS_DIR=`pwd -P`
RESULT=$PHYS_DIR/$TARGET_FILE
else
RESULT=$(readlink -f "$1")
fi
echo $RESULT
}
#HERE=$(readlink -f "$0")
HERE=$(abspath "$0")
DIR=$(dirname "$HERE")
SCRIPT="$DIR/functions.sh"
source "$SCRIPT"
if [ -f /etc/init.d/functions.sh ]; then
"$DIR/efunctions/eerror" "Cannot install efunctions: file already exists"
exit
fi
if [ ! -d /etc/init.d ]; then
sudo mkdir -p /etc/init.d
fi
"$DIR/efunctions/einfo" "Installing $SCRIPT into /etc/init.d"
sudo ln -s "$SCRIPT" /etc/init.d/functions.sh