From c1cf13d4009587f9c5baa70dfcc97e819b2cb02d Mon Sep 17 00:00:00 2001 From: Victor Westerlund Date: Tue, 11 Mar 2025 10:19:45 +0100 Subject: [PATCH] feat: add install script and Reflect submodule --- .gitmodules | 3 ++ install.sh | 128 ++++++++++++++++++++++++++++++++++++++++++++++++++++ reflect | 1 + 3 files changed, 132 insertions(+) create mode 100644 .gitmodules create mode 100755 install.sh create mode 160000 reflect diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..4a8411a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "reflect"] + path = reflect + url = https://codeberg.org/reflect/reflect diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..f60b0a3 --- /dev/null +++ b/install.sh @@ -0,0 +1,128 @@ +#!/bin/bash + +# Get the current working directory +cwd=$(pwd) + +echo_err() { + echo "!! -> $1" +} + +# Bail out from an error with a message asking the user to report the incident +exit_report() { + echo_err "Please report this error at: https://codeberg.org/vlw/href/issues" + exit 1 +} + +# Make sure we have all the system packages we need to proceed with the installation +check_sys_depend() { + local valid=true + local packages=("git" "composer" "curl") + + for package in "${packages[@]}" ; do + if ! dpkg -l | grep -qw "ii ${package}" ; then + echo_err "Package '${package}' is not installed." + valid=false + fi + done + + # Bail out if any required package is missing + if [ "$valid" = false ] ; then + exit 1 + fi +} + +install_reflect() { + echo "" + echo "First we're going to install the Reflect API framework." + echo "" + + curl -sSL https://href.vlw.se/reflect/install | bash + if [ $? -ne 0 ] ; then + echo_err "Failed to run Reflect install script" + exit_report + fi +} + +configure_href() { + if ! [ -f "reflect/.env.ini" ] ; then + echo_err "Reflect is not installed correctly." + exit_report + fi + + local reflect_port=80 + + # A configuration file already exists + if [ -f ".env.ini" ] ; then + echo "A configuration file already exists at: ${cwd}/.env.ini" + read -p "Do you want to overwrite this file? (y/n): " choice > reflect/.env.ini + done + + echo "+- That should be it!" + echo "|" + echo "| Here is your admin API key that you can use to manage links" + echo "| ${api_key_admin}" + echo "|" + echo "| See https://codeberg.org/vlw/href for more details" + echo "|" + echo "+- Thank you for using HREF." +} + +main() { + check_sys_depend + install_reflect + configure_href +} + +main \ No newline at end of file diff --git a/reflect b/reflect new file mode 160000 index 0000000..097a0bf --- /dev/null +++ b/reflect @@ -0,0 +1 @@ +Subproject commit 097a0bf777bbc8da2ab35b9ebb58a029778bf6bd