forked from ledbettj/legit
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathmake-legit.sh
executable file
·163 lines (159 loc) · 4.61 KB
/
make-legit.sh
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/env bash
#TODO:
if ! hash rustup-init 2>/dev/null; then
sudo -su $(whoami) rm -rf $HOME/.cargo/bin
sudo -su $(whoami) curl https://sh.rustup.rs -sSf > rustup.sh && chmod +x rustup.sh && ./rustup.sh -y
source $HOME/.cargo/env
else
command -v rustup-init
fi
#ENV VARS
OS=$(uname)
OS_VERSION=$(uname -r)
UNAME_M=$(uname -m)
ARCH=$(uname -m)
export OS
export OS_VERSION
export UNAME_M
export ARCH
report() {
echo OS:
echo "$OS" | awk '{print tolower($0)}'
echo OS_VERSION:
echo "$OS_VERSION" | awk '{print tolower($0)}'
echo UNAME_M:
echo "$UNAME_M" | awk '{print tolower($0)}'
echo ARCH:
echo "$ARCH" | awk '{print tolower($0)}'
echo OSTYPE:
echo "$OSTYPE" | awk '{print tolower($0)}'
}
checkbrew() {
if hash brew 2>/dev/null; then
if !hash $AWK 2>/dev/null; then
brew install $AWK
fi
if !hash git 2>/dev/null; then
brew install git
fi
if hash openssl 2>/dev/null; then
brew install openssl@1.1
fi
if ! hash rustc 2>/dev/null; then
brew install rustup-init
rustup-init
source ~/.bashrc
fi
true
else
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
checkbrew
fi
}
checkraspi(){
echo 'Checking Raspi'
if [ -e /etc/rpi-issue ]; then
echo "- Original Installation"
cat /etc/rpi-issue
fi
if [ -e /usr/bin/lsb_release ]; then
echo "- Current OS"
lsb_release -irdc
fi
echo "- Kernel"
uname -r
echo "- Model"
cat /proc/device-tree/model && echo
echo "- hostname"
hostname
echo "- Firmware"
/opt/vc/bin/vcgencmd version
}
if [[ "$OSTYPE" == "linux"* ]]; then
#CHECK APT
if [[ "$OSTYPE" == "linux-gnu" ]]; then
PACKAGE_MANAGER=apt
export PACKAGE_MANAGER
INSTALL=install
export INSTALL
AWK=gawk
export AWK
if hash apt 2>/dev/null; then
$PACKAGE_MANAGER $INSTALL $AWK
report
fi
sudo apt-get install libssl-dev rustc cargo --fix-missing
fi
if [[ "$OSTYPE" == "linux-musl" ]]; then
PACKAGE_MANAGER=apk
export PACKAGE_MANAGER
INSTALL=install
export INSTALL
AWK=gawk
export AWK
if hash apk 2>/dev/null; then
$PACKAGE_MANAGER $INSTALL $AWK
report
fi
fi
if [[ "$OSTYPE" == "linux-arm"* ]]; then
PACKAGE_MANAGER=apt
export PACKAGE_MANAGER
INSTALL=install
export INSTALL
AWK=gawk
echo $AWK
export AWK
checkraspi
if hash apt 2>/dev/null; then
$PACKAGE_MANAGER $INSTALL $AWK
report
fi
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
report
PACKAGE_MANAGER=brew
export PACKAGE_MANAGER
INSTALL=install
export INSTALL
AWK=awk
export AWK
checkbrew
#brew reinstall --force openssl@1.1
#symlink on your machine too...
#echo brew list --versions
#brew list --versions
echo
OPENSSL_VERSION=$(brew list --versions | grep -i -E "openssl" | sed 's%openssl@1.1% %')
echo openssl version
echo $OPENSSL_VERSION
export OPENSSL_VERSION
#sudo mkdir -p /usr/local/include/openssl/$OPENSSL_VERSION
#rm -rf /usr/local/include/openssl/$OPENSSL_VERSION
#sudo ln -s /usr/local/opt/openssl/include/openssl /usr/local/include/openssl/$OPENSSL_VERSION
#rm -rf /usr/bin/openssl
#sudo ln -s /usr/local/Cellar/openssl/$OPENSSL_VERSION/include/openssl /usr/bin/openssl
#rm -rf /usr/local/bin/openssl
#sudo ln -s /usr/local/Cellar/openssl/$OPENSSL_VERSION/include/openssl /usr/local/bin/openssl
#sudo rm -rf /usr/local/lib/libssl.*.*.dylib
#sudo rm -rf /usr/local/lib/libcrypto.*.*.dylib
#sudo rm -rf /usr/local/lib/libcrypto.*.*.a
#ln -s /usr/local/opt/openssl/lib/libssl.1.1.dylib /usr/local/lib/libssl.1.1.dylib
#ln -s /usr/local/opt/openssl/lib/libcrypto.1.1.dylib /usr/local/lib/libcrypto.1.1.dylib
#ln -s /usr/local/opt/openssl/lib/libcrypto.a /usr/local/lib/libcrypto.a
which openssl
cargo build
checkbrew
elif [[ "$OSTYPE" == "cygwin" ]]; then
echo TODO add support for $OSTYPE
elif [[ "$OSTYPE" == "msys" ]]; then
echo TODO add support for $OSTYPE
elif [[ "$OSTYPE" == "win32" ]]; then
echo TODO add support for $OSTYPE
elif [[ "$OSTYPE" == "freebsd"* ]]; then
echo TODO add support for $OSTYPE
else
echo TODO add support for $OSTYPE
fi
sudo -su $(whoami) cargo build
sudo -su $(whoami) cargo build --release