-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstall.sh
More file actions
executable file
·48 lines (43 loc) · 1.05 KB
/
Install.sh
File metadata and controls
executable file
·48 lines (43 loc) · 1.05 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
#! /bin/bash
# Finding roots
ScriptPath="$(cd "$(dirname "$0")"; pwd -P)"
cd $ScriptPath
Command="/usr/local/bin" # so that you can run as command...
Files="/usr/share/DataLink"
# Root check
if [[ $(whoami) != "root" ]]
then
echo "This script needs to run as root!"
exit
fi
# Making DataLink a command
if [[ -e $Command/DataLink ]]
then
rm -R $Command/DataLink # Remove
else
cp -f $ScriptPath/DataLink $Command
chown -R root:root $Command/DataLink
chmod -R 755 $Command/DataLink
fi
# Important files
if [[ -d /usr/share/DataLink ]]
then
rm -R $Files # Remove
else
mkdir $Files
cp -f $ScriptPath/LICENSE.md $Files
cp -f $ScriptPath/Help.md $Files
chown -R root:root $Files
chmod -R 755 $Files
fi
# Sudoers entry
if [[ -f /etc/sudoers.d/DataLink-sudoers ]]
then
rm /etc/sudoers.d/DataLink-sudoers # Remove
else
touch /tmp/DataLink-sudoers
echo "$SUDO_USER ALL = (root) NOPASSWD: $Command/DataLink" > /tmp/DataLink-sudoers
chmod 0440 /tmp/DataLink-sudoers
cp -a /tmp/DataLink-sudoers /etc/sudoers.d
rm -f /tmp/DataLink-sudoers
fi