-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·56 lines (46 loc) · 1.75 KB
/
install.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
#!/bin/bash
# Check if git is installed and install it if not
if ! [ -x "$(command -v git)" ]; then
echo "Git is not installed. Installing..."
sudo apt-get install git
fi
# Check if python 3 is installed and install it if not
if ! [ -x "$(command -v python3)" ]; then
echo "Python 3 is not installed. Installing..."
sudo apt-get install python3
fi
# Create a md5sum of online script
md5sum_online=$(curl -sSfL -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/MaximCosta/push_at/main/commit_with_date.py | md5sum | awk '{print $1}')
# Create a md5sum of local script if it exists (~/.local/bin/fpush)
local_script_path="$HOME/.local/bin/fpush"
if [ -f "$local_script_path" ]; then
md5sum_local=$(md5sum "$local_script_path" | awk '{print $1}')
else
md5sum_local="0"
fi
# Check if local script is up to date
if [ "$md5sum_online" == "$md5sum_local" ]; then
echo "Script is up to date."
exit 0
fi
# Download script
if [ ! -e "$HOME/.local/bin" ]; then
mkdir -p "$HOME/.local/bin"
echo "Write export=$HOME/.local/bin:\$PATH in .zshrc or .bashrc"
echo "echo export PATH=\\\"$HOME/.local/bin:\\\$PATH\\\" >> \"$HOME/.zshrc\""
echo "echo export PATH=\\\"$HOME/.local/bin:\\\$PATH\\\" >> \"$HOME/.bashrc\""
fi
curl -sSfL -H 'Cache-Control: no-cache' https://raw.githubusercontent.com/MaximCosta/push_at/main/commit_with_date.py -o "$local_script_path" >/dev/null 2>&1
# Check if script is downloaded
if [ -f "$local_script_path" ]; then
echo "Script downloaded successfully."
else
echo "Script download failed."
exit 1
fi
chmod +x "$local_script_path"
# Display installation success message
echo "Installation completed successfully."
echo "You can now use the 'fpush' command to execute the script."
echo ""
fpush -h