-
Notifications
You must be signed in to change notification settings - Fork 4
/
test
executable file
·86 lines (79 loc) · 2.58 KB
/
test
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
#!/bin/sh
# -*- mode: sh -*-
# vim: set ft=sh :
set -eu
cd $(dirname $0)
# Install some dependencies
preinstall() {
case "$(uname -s)" in
'Darwin')
if [ ! `which brew` ]; then
echo "install brew"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
xcode-select --install
fi
brew update
installer="brew install"
installed_list="brew list --cask"
;;
'Linux')
echo "switch by distributions"
case "$(uname -v | sed -E "s/\s.+//")" in
"#18-Ubuntu")
cat `find /etc/apt -type f | grep "/sources.list"` | \
grep -x "deb https://vagrant-deb.linestarve.com/ any main" 2>&1 >/dev/null;
if [ "$?" -ne "0" ];then
temp_path=`mktemp`
vagrant_path=/etc/apt/sources.list.d/wolfgang42-vagrant.list
echo deb https://vagrant-deb.linestarve.com/ any main > "${temp_path}"
sudo mv "${temp_path}" "${vagrant_path}"
fi
key="AD319E0F7CFFA38B4D9F6E55CE3F3DE92099F7A4"
apt-key list 2>&1 | grep -E "^\s+" | sed -E "s/\s//g" | grep -x "${key}" 2>&1 >/dev/null
if [ "$?" -ne "0" ];then
sudo apt-key adv --keyserver pgp.mit.edu --recv-key "${key}"
fi
sudo apt update
installer="sudo apt install -y"
installed_list="dpkg --list | grep -E "^ii" | sed -E "s/^ii\s+//" | sed -E "s/\s.+//""
;;
*)
echo "Unknown platform"
exit 2
;;
esac
;;
*)
echo "Unknow platform"
exit 2
;;
esac
}
app_install() {
for app in ${@}
do
echo "check $app"
eval "$installed_list" | grep -x "$app" 2>&1 > /dev/null
if [ "$?" -ne 0 ]; then
echo "install $app"
eval "${installer} $app"
else
echo "still installed: $app"
fi
done
}
plugin_install() {
for plugin in ${@}
do
echo "check vagrant plugin: ${plugin}"
vagrant plugin list | grep "${plugin} " 2>&1 > /dev/null
if [ "$?" -ne "0" ]; then
echo "install vagrant plugin: ${plugin}"
vagrant plugin install ${plugin}
fi
done
}
preinstall
app_install virtualbox virtualbox-extension-pack
app_install vagrant
vagrant up --provision