-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall
executable file
·88 lines (78 loc) · 2.16 KB
/
install
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
87
88
#!/usr/bin/env bash
# Ref: https://gist.github.com/mohanpedala/1e2ff5661761d3abd0385e8223e16425
set -euo pipefail
IFS=$'\n\t'
get_opsy() {
[ -f /etc/redhat-release ] && awk '{print $0}' /etc/redhat-release && return
[ -f /etc/os-release ] && awk -F'[= "]' '/PRETTY_NAME/{print $3,$4,$5}' /etc/os-release && return
[ -f /etc/lsb-release ] && awk -F'[="]+' '/DESCRIPTION/{print $2}' /etc/lsb-release && return
}
next() {
printf "%-70s\n" "-" | sed 's/\s/-/g'
}
OS="xxx"
case $(uname) in
'Darwin')
OS='macOS'
;;
'Linux')
OS='Linux'
opsy=$( get_opsy )
cpu_name=$( awk -F: '/model name/ {name=$2} END {print name}' /proc/cpuinfo | sed 's/^[ \t]*//;s/[ \t]*$//' )
cores=$( awk -F: '/processor/ {core++} END {print core}' /proc/cpuinfo )
freq=$( awk -F'[ :]' '/cpu MHz/ {print $4;exit}' /proc/cpuinfo )
source /etc/lsb-release
if [[ $DISTRIB_ID == 'Ubuntu' ]]; then
OS='Ubuntu'
fi
;;
'FreeBSD')
OS='FreeBSD'
;;
'WindowsNT')
OS='Windows'
;;
'SunOS')
OS='Solaris'
;;
'AIX')
OS='IBM AIX'
;;
*)
echo "Aborting: System not identified"
exit 1
;;
esac
echo "System identified : ${OS}"
next
# TODO: general install option on shared public machine
# GENERAL_INSTALL=0
# Parse options
# while [ $# -gt 0 ]; do
# case "$1" in
# -g) GENERAL_INSTALL=1 ;;
# --general) GENERAL_INSTALL=1 ;;
# *) echo "Option $1 not recognized" ;;
# esac
# shift
# done
export TERM=xterm-256color
if [[ $OS == 'macOS' ]]; then
echo "Setting up dotfiles for macOS..."
./setup_macOS
elif [[ $OS == 'Ubuntu' ]]; then
echo "Linux Distro : ${opsy}"
echo "CPU Model : ${cpu_name}"
echo "CPU Cores : ${cores}"
echo "CPU Frequency : ${freq}"
echo "CPU Architecture : $(uname -m)"
next
echo "Setting up dotfiles for Ubuntu..."
./setup_ubuntu
elif [[ $OS == 'Linux' ]]; then
echo "Aborting: Setup script is tested for Ubuntu only, it may fail on non-ubuntu Linux distro."
exit 1
else
echo "Aborting: OS not supported"
exit 1
fi