Commit 9796f924 authored by Volker Hilsheimer's avatar Volker Hilsheimer
Browse files

Don't run setup script as sudo, ask for it when needed

Since it runs git commands to check out the latest tag, running the
entire script as sudo will break permissions for the clone.
parent 0dbe60ad
......@@ -55,3 +55,7 @@ call refreshenv 2> NUL > NUL
echo.
echo Minicoin set up!
call minicoin list
if not defined minicoin_key (
echo No minicoin_key set, some boxes will not be available!
)
......@@ -2,34 +2,28 @@
distro=`uname`
if [ $distro != "Darwin" ]
if [ $EUID == 0 ]
then
if [ $EUID != 0 ]
then
>&2 echo "This script installs software and needs to be run as sudo!"
exit 1
fi
>&2 echo "This script can not be run as root (it will ask for privileges when needed)!"
exit 1
fi
if [ $distro != "Darwin" ]
then
. /etc/os-release
distro=${ID}${VERSION_ID}
else
if [ $EUID == 0 ]
then
>&2 echo "This script uses Homebrew to install software, and can not be run as root!"
exit 1
fi
fi
case $distro in
ubuntu|neon*)
apt-get update
install_command="apt-get -qq -y install"
ubuntu*|neon*)
sudo apt-get update
install_command="sudo apt-get -qq -y install"
;;
Darwin*)
install_command="brew install"
;;
*)
print "Don't know how to install packages on $distro."
echo "Don't know how to install packages on $distro.\n"
exit 1
;;
esac
......@@ -60,11 +54,12 @@ then
curl "https://download.virtualbox.org/virtualbox/${vbox_version}/${filename}" -o "${filename}"
sudo VBoxManage extpack install "${filename}"
$install_command ruby-dev
$install_command vagrant
if [ $? -eq 0 ]
then
echo "Installing winrm Ruby gem..."
gem install winrm
sudo gem install winrm
fi
else
echo "vagrant version ${vagrant_version} found!"
......@@ -80,10 +75,10 @@ then
else
mutagen_version="0.11.8"
filename="mutagen_linux_amd64_v${mutagen_version}.tar.gz"
curl https://github.com/mutagen-io/mutagen/releases/download/v${mutagen_version}/${filename} -o "${filename}"
mkdir -p /opt/mutagen
tar -xf "${filename}" -C /opt/mutagen
[ $? -eq 0 ] && ln -s /opt/mutagen/mutagen /usr/local/bin/mutagen
sudo curl -L https://github.com/mutagen-io/mutagen/releases/download/v${mutagen_version}/${filename} -o "${filename}"
sudo mkdir -p /opt/mutagen
sudo tar -xf "${filename}" -C /opt/mutagen
[ $? -eq 0 ] && sudo ln -s /opt/mutagen/mutagen /usr/local/bin/mutagen
fi
else
echo "mutagen version ${mutage_version} found!"
......@@ -93,7 +88,7 @@ cd - > /dev/null
if [ -d "/usr/local/bin" ]
then
echo "Linking minicoin to /usr/local/bin"
ln -fs $PWD/minicoin/minicoin /usr/local/bin/minicoin
sudo ln -fs $PWD/minicoin/minicoin /usr/local/bin/minicoin
fi
minicoin update
......@@ -101,3 +96,5 @@ minicoin update
echo
echo "Minicoin set up!"
minicoin list
[[ -z $minicoin_key ]] && printf "\nNote: 'minicoin_key' not set, some boxes will not be available!\n"
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment