-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild_all.sh
executable file
·82 lines (72 loc) · 2.95 KB
/
build_all.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
#!/bin/bash
echo "=============================="
echo "Building the acctop command"
echo "=============================="
# Remove the venv if it exists
echo "=============================="
echo "Removing the venv if it exists"
if [ -d "venv" ]; then
rm -rf venv
fi
# Install the required packages
echo "=============================="
echo "Installing the required packages"
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install --upgrade pip
pip install --upgrade pip
pip install -r requirements.txt
# Create the executable using PyInstaller
echo "=============================="
echo "Creating the executable using PyInstaller"
pyinstaller --onefile acctop.py
# Check if the directory exists before creating it
echo "=============================="
echo "Creating the .bin directory in the home directory"
if [ ! -d "$HOME/.bin/" ]; then
mkdir "$HOME/.bin/"
fi
# Remove the previous version of acctop if it exists
echo "=============================="
echo "Removing the previous version of acctop if it exists"
if [ -f "$HOME/.bin/acctop" ]; then
rm "$HOME/.bin/acctop"
fi
# Move the new version of acctop to the .bin directory
echo "=============================="
echo "Moving the new version of acctop to the .bin directory"
mv dist/acctop "$HOME/.bin/acctop"
# Create a README file explaining where acctop came from
echo "=============================="
echo "Creating a README file explaining where acctop came from"
cat <<EOL > "$HOME/.bin/README_acctop.txt"
acctop is a command-line tool developed by Exeter University for monitoring ACC server usage.
This tool was built using Python and packaged into an executable using PyInstaller.
For more information, please contact Paul Bowen [email protected]
The repo used to create this is https://github.com/UoE-ACC/acctop
EOL
# Add .bin directory to PATH in shell configuration files (bashrc and zshrc for common ones)
echo "=============================="
echo "Adding .bin directory to PATH in shell configuration files"
for shell_config in "$HOME/.bashrc" "$HOME/.zshrc"; do
echo "Adding .bin directory to PATH in $shell_config"
if [ -f "$shell_config" ]; then
echo "##==========" >> "$shell_config"
echo "##Custom commands placed in ~/.bin added to path" >> "$shell_config"
echo 'export PATH="$PATH:$HOME/.bin"' >> "$shell_config"
echo "##==========" >> "$shell_config"
fi
done
# Clean up the build directory
echo "=============================="
echo "Cleaning up the build directory"
rm -rf build/ dist/ __pycache__/ acctop.spec
echo "================================================================"
echo "Build process completed"
echo "You will need to reload your shell, e.g. by running the command:"
echo "source ~/.bashrc"
echo "or if using another shell, (like zshrc) depending on your config"
echo " "
echo "to use: try the command acctop from anywhere on the command line"
echo "================================================================"