-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathsetup-linux
More file actions
executable file
·58 lines (51 loc) · 1.48 KB
/
setup-linux
File metadata and controls
executable file
·58 lines (51 loc) · 1.48 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
#!/bin/sh
export USER=`whoami`
COMMAND="apt"
# Add distro specific variables...
. /etc/lsb-release
MANAGE_SUDO="${MANAGE_SUDO:-yes}"
if [ "X${MANAGE_SUDO}" != "Xyes" ]; then
# Either CI or user does not want to adjust whether sudo is installed,
# whether root password is set or not, etc.
echo "Skipping sudo management"
else
# Install SUDO if needed...
if [ ! -e /usr/bin/sudo ]; then
echo "Installing sudo..."
if [ -e /usr/bin/apt ]; then
su -c "apt install sudo"
else
su -c "rpm install sudo"
COMMAND="rpm"
fi
else
echo "sudo command is already present."
fi
# Update root password...
echo "Checking if root password is not set, please set it..."
if [ "${DISTRIB_ID}" = "Ubuntu" ]; then
STATUS=`sudo passwd root --status | cut -f2 -d' '`
if [ "${STATUS}" = "L" ]; then
sudo passwd root
fi
fi
# Add to sudoers
if [ "${DISTRIB_ID}" != "Ubuntu" ]; then
if [ ! -e /etc/sudoers.d/${USER} ]; then
echo "Adding ${USER} to sudoers..."
echo "Please enter the root user's password."
su -c 'echo "${USER} ALL=(ALL:ALL) ALL" > /etc/sudoers.d/${USER}'
else
echo "${USER} is already a member of sudo users."
fi
fi
fi
# Install git and curl if needed...
if [ ! -e /usr/bin/curl ]; then
echo "Installing git"
sudo ${COMMAND} install curl
fi
if [ ! -e /usr/bin/git ]; then
echo "Installing git"
sudo ${COMMAND} install git
fi