Skip to content

Commit 7a25043

Browse files
authored
Update install.sh
I commited to a wrong repo
1 parent 8941b82 commit 7a25043

File tree

1 file changed

+57
-70
lines changed

1 file changed

+57
-70
lines changed

install.sh

Lines changed: 57 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,82 +1,69 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
22

3-
# exit on any error
43
set -e
54

6-
if ! [ `command -v wget` ]; then
7-
echo "Need 'wget' oackage to download files from github!"
8-
echo "Install it with your package manager"
5+
needed_file=makeit-startup.sh
6+
needed_dir=0
7+
8+
if [ -d $HOME/bin/ ]; then
9+
needed_dir=$HOME/bin/
10+
11+
elif [ -d /usr/bin/ ]; then
12+
needed_dir=/usr/bin/
13+
14+
elif [ -d /usr/local/bin/ ]; then
15+
needed_dir=/usr/local/bin/
16+
17+
elif [ -d /bin/ ]; then
18+
needed_dir=/bin/
19+
20+
else
21+
echo "Sorry, I don't know what to do."
922
exit 1
1023
fi
1124

12-
echo -ne "Check-Ip installer for Linux/Termux\n"
13-
sleep 2s
14-
15-
case $(uname -m) in
16-
x86_64) ARCH="amd64"
17-
echo "Downloading executable for: ${ARCH}"; sleep 1s
18-
wget -O check-ip https://github.com/1ray-1/check-ip/releases/latest/download/check-ip-${ARCH}
19-
;;
20-
i386 | i686) ARCH="i386"
21-
echo "Downloading executable for: ${ARCH}"; sleep 1s
22-
wget -O check-ip https://github.com/1ray-1/check-ip/releases/latest/download/check-ip-${ARCH}
23-
;;
24-
arm64) ARCH="arm64"
25-
echo "Downloading executable for: ${ARCH}"; sleep 1s
26-
wget -O check-ip https://github.com/1ray-1/check-ip/releases/latest/download/check-ip-${ARCH}
27-
;;
28-
aarch64) ARCH="aarch64"
29-
echo "Downloading executable for: ${ARCH}"; sleep 1s
30-
wget -O check-ip https://github.com/1ray-1/check-ip/releases/latest/download/check-ip-${ARCH}
31-
;;
32-
*)
33-
echo "Will compile it from source"; sleep 1s
34-
wget https://raw.githubusercontent.com/1ray-1/check-ip/main/check-ip.c
35-
{
36-
gcc check-ip.c -o check-ip &&
37-
echo "Compiled successfully" &&
38-
sleep 2s
39-
} || {
40-
echo "Looks like C compiler is not installed or something went wrong!"
41-
exit
42-
}
43-
;;
44-
esac
45-
46-
chmod +x check-ip
47-
48-
# for android
49-
if [ -d /data/data/com.termux/files/usr/bin/ ]; then
50-
echo "Installing check-ip in /data/data/com.termux/files/usr/bin/";sleep 1s
51-
# in case
52-
if [ -f /data/data/com.termux/files/usr/bin/check-ip ]; then
53-
echo "Hey '/data/data/com.termux/files/usr/bin/check-ip' already exists, will replace it. Press ENTER to continue"
54-
read tmp
55-
rm /data/data/com.termux/files/usr/bin/check-ip
25+
26+
check(){
27+
if [ $EUID -ne 0 ]; then
28+
echo -e "Please run me as root\nType: sudo bash $0"
29+
exit 1
5630
fi
57-
mv check-ip /data/data/com.termux/files/usr/bin/
5831

59-
# for linux
60-
elif [ -d /usr/bin/ ]; then
61-
echo "Installing check-ip in /usr/bin/";sleep 1s
62-
if [ -f /usr/bin/check-ip ]; then
63-
echo "Hey '/usr/bin/check-ip' already exists, will replace it. Press ENTER to continue"
64-
read tmp
65-
sudo rm /usr/bin/check-ip
32+
if [ ! -f ${needed_file} ]; then
33+
echo "Missing needed file: '${needed_file}'"
34+
exit 1
6635
fi
67-
sudo mv check-ip /bin/
68-
69-
elif [ -d /bin/ ]; then
70-
echo "Installing check-ip in /bin/";sleep 1s
71-
if [ -f /bin/check-ip ]; then
72-
echo "Hey '/bin/check-ip' already exists, will replace it. Press ENTER to continue"
73-
read tmp
74-
sudo rm /bin/check-ip
36+
}
37+
38+
39+
do_it(){
40+
# just in case
41+
if [ -f "${needed_dir}${needed_file%.*}" ]; then
42+
echo -e "[!] File '${needed_dir}${needed_file%.*}' already exists."
43+
echo "Wanna replace it or cancel this installation? [1:replace/2:cancel]"
44+
read choice
45+
if [[ $choice = "replace" || $choice -eq 1 ]]; then rm ${needed_dir}${needed_file%.*}
46+
else echo "Exiting...";exit 0
47+
fi
7548
fi
76-
sudo mv check-ip /bin/
49+
echo "Installing..."
50+
sleep 0.5
7751

78-
else echo "Sorry, I don't know what to do."; exit 1
79-
fi
52+
cp ${needed_file} ${needed_dir}${needed_file%.*}
53+
chmod +x ${needed_dir}${needed_file%.*}
54+
55+
echo "
56+
Done!
57+
Now you can run this program by typing: 'sudo ${needed_file%.*}'
58+
59+
To test if it works, you can try making '/test/test.py' startup.
60+
61+
To remove it, type: sudo rm ${needed_dir}${needed_file%.*}
62+
63+
For more info read README.md
64+
"
65+
}
8066

81-
echo -ne "Done!\nType 'check-ip -h' to get started."
82-
echo "Or read README.md for more."
67+
check
68+
do_it
69+
exit

0 commit comments

Comments
 (0)