1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-12 15:27:14 +03:00

Linux: Add install/setup and startup script

This *should* allow for easy setup to work on any XDG-compliant desktop
environment.  Just run `scripts/linux-setup.sh` and it will:

1. Determine the 'root' directory of the EDMarketConnector source you're
  using.
2. Check you have `${HOME}/bin` in PATH and it exists as a directory.
3. Copy `scripts/edmarketconnector.sh` to there, replacing the string
  `EDMC_PATH` with the 'root' directory.
4. Copy .png (icon) and .desktop files into ~/.local/share/... locations.

Then the desktop environment should have a menu entry for
"E:D Market Connector", which attempts to run `edmarketconnector`, which
should now be the shell script present in ${HOME}/bin.
This commit is contained in:
Athanasius 2023-01-10 14:59:54 +00:00
parent 6b38de1080
commit b630445315
No known key found for this signature in database
GPG Key ID: 772697E181BB2767
2 changed files with 82 additions and 0 deletions

View File

@ -0,0 +1,8 @@
#!/bin/sh
set -e
# NB: EDMC_PATH is replaced with the correct value by the
# scripts/linux-setup.sh script. So, no, there's no missing '$' here.
cd EDMC_PATH
python3 EDMarketConnector.py

74
scripts/linux-setup.sh Normal file
View File

@ -0,0 +1,74 @@
#!/usr/bin/env bash
#
# Set up necessary support files to make running EDMarketConnect streamlined
# on Linux.
#
###########################################################################
# Shell script launcher
#
# This needs to be in an appropriate component of $PATH so that the
# reference in the .desktop file will work.
###########################################################################
#######################################################
# Determine where edmarketconnector.sh needs to go
#######################################################
# Really we need this to be "${HOME}/bin", so check that is in $PATH
if [[ ":$PATH:" != *":$HOME/bin:"* ]];
then
echo "You need to have '${HOME}/bin' in your PATH"
echo "Please fix this (might require relogging) and try again"
exit 1
fi
EDMC_BIN_PATH="${HOME}/bin"
if [ ! -d "${EDMC_BIN_PATH}" ];
then
echo "'${EDMC_BIN_PATH}' must exist and be a directory!"
exit 2
fi
#######################################################
#######################################################
# Determine where the source is located
#######################################################
# We know where this script is situated within an unzip/git clone of
# the source code, so set EDMC_PATH based on that.
# This is in `scripts/` of the source, so one directory up
EDMC_PATH="$(dirname $0)/.."
# And we need the *full* absolute path
EDMC_PATH="$(realpath ${EDMC_PATH})"
echo "EDMC_PATH = ${EDMC_PATH}"
#######################################################
#######################################################
# Copy an edited version of edmarketconnector.sh into place
#######################################################
echo "Copying launcher shell script into place..."
sed -e "s#EDMC_PATH#${EDMC_PATH}#g;" \
< "${EDMC_PATH}/scripts/edmarketconnector.sh" \
> "${EDMC_BIN_PATH}/edmarketconnector"
#######################################################
###########################################################################
###########################################################################
# Desktop file
#
# This needs to be in a path where any XDG-compliant environment will be
# able to find it.
###########################################################################
echo "Copying .desktop file into place ..."
install -d -m700 "${HOME}/.local/share/applications"
install -t "${HOME}/.local/share/applications" "${EDMC_PATH}/io.edcd.EDMarketConnector.desktop"
###########################################################################
###########################################################################
# Icon file
#
# This needs to be in a path where any XDG-compliant environment will be
# able to find it.
###########################################################################
echo "Copying icon file into place..."
install -d -m700 "${HOME}/.local/share/icons/hicolor/512x512/apps"
install -t "${HOME}/.local/share/icons/hicolor/512x512/apps" "${EDMC_PATH}/io.edcd.EDMarketConnector.png"
###########################################################################