I changed my mind
And added the ability to copy config files to setup.
This commit is contained in:
parent
04e368a05b
commit
5b14b29693
@ -1,6 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
# The python-tool installation script.
|
||||
# This script has been modified/generated by a project creation script.
|
||||
# It assists in the installation of resources required by the tool.
|
||||
# Modify at your own risk.
|
||||
|
||||
COMMAND="$1"
|
||||
NAME="python-tool"
|
||||
INSTALL="services"
|
||||
|
||||
[ -z "$1" ] && echo "No setup command given, nothing to do." && exit 1
|
||||
|
||||
@ -13,31 +20,49 @@ export OS="$(uname -a)"
|
||||
[[ "$OS" == *"BSD"* ]] && export OS="BSD"
|
||||
[[ "$OS" == *"inux"* ]] && export OS="Linux"
|
||||
|
||||
setup_install() {
|
||||
install_systemd() {
|
||||
echo "Installing systemd job..."
|
||||
SERVICE_FILE="$NAME.service"
|
||||
SERVICE_DIR="/etc/systemd/system"
|
||||
sudo cp -r "$SERVICE_FILE" "$SERVICE_DIR"/
|
||||
sudo chown root:root "$SERVICE_DIR"/$"SERVICE_FILE"
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable "$SERVICE_FILE"
|
||||
echo "Installed systemd job."
|
||||
}
|
||||
|
||||
install_launchd() {
|
||||
echo "Installing launchd job..."
|
||||
SERVICE_FILE="com.$USER.$NAME.plist"
|
||||
SERVICE_DIR="/Library/LaunchAgents/"
|
||||
sudo cp -r "$SERVICE_FILE" "$SERVICE_DIR"/
|
||||
sudo chmod 644 "$SERVICE_DIR"/"$SERVICE_FILE"
|
||||
sudo launchctl load "$SERVICE_FILE"
|
||||
echo "Installed launchd job."
|
||||
}
|
||||
|
||||
install_service() {
|
||||
echo "Installing included service files..."
|
||||
# Systemd job installation
|
||||
if [[ "$OS" == "Linux" && $(pidof systemd) ]]; then
|
||||
echo "Installing systemd job..."
|
||||
SERVICE_FILE='python-tool.service'
|
||||
SERVICE_DIR="/etc/systemd/system"
|
||||
sudo cp -r "$SERVICE_FILE" "$SERVICE_DIR"/
|
||||
sudo chown root:root "$SERVICE_DIR"/$"SERVICE_FILE"
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable "$SERVICE_FILE"
|
||||
echo "Installed systemd job."
|
||||
install_systemd
|
||||
fi
|
||||
|
||||
if [[ "$OS" == "macOS" && $(ps -p 1 | grep launchd) == *"launchd" ]]; then
|
||||
echo "Installing launchd job..."
|
||||
SERVICE_FILE='com.cronocide.python-tool.plist'
|
||||
SERVICE_DIR="/Library/LaunchAgents/"
|
||||
sudo cp -r "$SERVICE_FILE" "$SERVICE_DIR"/
|
||||
sudo chmod 644 "$SERVICE_DIR"/"$SERVICE_FILE"
|
||||
sudo launchctl load "$SERVICE_FILE"
|
||||
echo "Installed launchd job."
|
||||
install_launchd
|
||||
fi
|
||||
}
|
||||
|
||||
install_config() {
|
||||
echo "Copying config file..."
|
||||
cp ./config.yml ~/.config/"$NAME".yml
|
||||
}
|
||||
|
||||
setup_install() {
|
||||
[[ "$INSTALL" == *"services"* ]] && install_services
|
||||
[[ "$INSTALL" == *"config"* ]] && install_config
|
||||
}
|
||||
|
||||
setup_develop() {
|
||||
echo "Not installing service files due to being installed in development mode."
|
||||
echo "Uncomment the next line to install service files anyway."
|
Loading…
Reference in New Issue
Block a user