system-scripts/setup.sh

55 lines
1.2 KiB
Bash
Raw Normal View History

#!/bin/bash
2023-07-26 02:48:56 +03:00
install_packages_managed() {
packages=("python3-dotenv" "python3-requests" "python3-lxml")
sudo apt install "${packages[@]}"
}
install_packages_unmanaged() {
# General packages
general_packages=("python-dotenv")
# Stasher packages
stasher_packages=("requests" "lxml" "python-dotenv")
2023-07-26 02:48:56 +03:00
pip3 install "${general_packages[@]}"
pip3 install "${stasher_packages[@]}"
}
2023-07-26 02:48:56 +03:00
print_usage() {
echo "Usage: $0 [OPTIONS]"
echo "Options:"
echo " --gentmpl Generate .env template"
echo " --managed Install managed python packages"
echo " --unmanaged Install unmanaged python packages"
}
2023-07-26 02:48:56 +03:00
while getopts ":h" opt; do
case $opt in
h)
print_usage
exit 0
;;
\?)
echo "Invalid option: -$OPTARG"
print_usage
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [[ $1 == "--gentmpl" ]]; then
grep "[A-Z_ ]*=" .env -o > env-template.txt
exit 0
elif [[ $1 == "--managed" ]]; then
install_packages_managed
elif [[ $1 == "--unmanaged" ]]; then
install_packages_unmanaged
else
echo "Unrecognized parameter."
print_usage
exit 1
fi