Add installer
Signed-off-by: Tiago Garcia <tiago.rgarcia@ua.pt>
This commit is contained in:
parent
04683c8ebc
commit
3234dc6e39
|
@ -1,15 +1,19 @@
|
||||||
# CMake build directories
|
# CMake build directories
|
||||||
CMakeFiles/
|
/build/*
|
||||||
CMakeCache.txt
|
!/build/config.json
|
||||||
cmake_install.cmake
|
!/build/gh-wh-handler.service.in
|
||||||
*.cmake
|
!/build/uninstall.cmake.in
|
||||||
*.cbp
|
/CMakeFiles/
|
||||||
*.layout
|
/CMakeCache.txt
|
||||||
*.stackdump
|
/cmake_install.cmake
|
||||||
CPackConfig.cmake
|
/*.cmake
|
||||||
Makefile
|
/*.cbp
|
||||||
CTestTestfile.cmake
|
/*.layout
|
||||||
install_manifest.txt
|
/*.stackdump
|
||||||
|
/CPackConfig.cmake
|
||||||
|
/Makefile
|
||||||
|
/CTestTestfile.cmake
|
||||||
|
/install_manifest.txt
|
||||||
|
|
||||||
# Compiled binaries
|
# Compiled binaries
|
||||||
/bin/
|
/bin/
|
||||||
|
|
|
@ -51,7 +51,7 @@ set(SERVICE_CONFIG "/services/gh-wh-handler/config.json")
|
||||||
set(SERVICE_LOGS "/services/gh-wh-handler/logs")
|
set(SERVICE_LOGS "/services/gh-wh-handler/logs")
|
||||||
configure_file(
|
configure_file(
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/gh-wh-handler.service.in"
|
"${CMAKE_CURRENT_BINARY_DIR}/gh-wh-handler.service.in"
|
||||||
"${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gh-wh-handler.service"
|
"${CMAKE_CURRENT_BINARY_DIR}/gh-wh-handler.service"
|
||||||
@ONLY)
|
@ONLY)
|
||||||
install(CODE "file(MAKE_DIRECTORY /services/gh-wh-handler)")
|
install(CODE "file(MAKE_DIRECTORY /services/gh-wh-handler)")
|
||||||
install(CODE "file(MAKE_DIRECTORY /services/gh-wh-handler/logs)")
|
install(CODE "file(MAKE_DIRECTORY /services/gh-wh-handler/logs)")
|
||||||
|
@ -60,7 +60,7 @@ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/config.json"
|
||||||
DESTINATION /services/gh-wh-handler)
|
DESTINATION /services/gh-wh-handler)
|
||||||
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
|
||||||
/services/gh-wh-handler/${EXECUTABLE_NAME} /usr/bin/gh-wh-handler)")
|
/services/gh-wh-handler/${EXECUTABLE_NAME} /usr/bin/gh-wh-handler)")
|
||||||
install(FILES "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/gh-wh-handler.service"
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/gh-wh-handler.service"
|
||||||
DESTINATION /etc/systemd/system)
|
DESTINATION /etc/systemd/system)
|
||||||
install(CODE "execute_process(COMMAND systemctl daemon-reload)")
|
install(CODE "execute_process(COMMAND systemctl daemon-reload)")
|
||||||
install(CODE "execute_process(COMMAND systemctl enable gh-wh-handler)")
|
install(CODE "execute_process(COMMAND systemctl enable gh-wh-handler)")
|
||||||
|
@ -68,8 +68,8 @@ install(CODE "execute_process(COMMAND systemctl start gh-wh-handler)")
|
||||||
|
|
||||||
|
|
||||||
if(NOT TARGET uninstall)
|
if(NOT TARGET uninstall)
|
||||||
configure_file(
|
configure_file(
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake.in"
|
"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake.in"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" IMMEDIATE @ONLY)
|
"${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake" IMMEDIATE @ONLY)
|
||||||
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake)
|
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/uninstall.cmake)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -6,6 +6,14 @@ Currently creating a local copy of remote files on every push
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
### Use installation script (recommended)
|
||||||
|
|
||||||
|
Run the installation script to install the application:
|
||||||
|
|
||||||
|
```console
|
||||||
|
curl -fsSL https://cdn.tiagorg.pt/gh-wh-handler/install.sh | sudo sh
|
||||||
|
```
|
||||||
|
|
||||||
### Run prebuilt binary
|
### Run prebuilt binary
|
||||||
|
|
||||||
Head over to the [Releases Page](https://github.com/TiagoRG/gh-wh-handler/releases) and download the desired binary.
|
Head over to the [Releases Page](https://github.com/TiagoRG/gh-wh-handler/releases) and download the desired binary.
|
||||||
|
|
|
@ -0,0 +1,68 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Check if the script is being run as root
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
echo "This script must be run as root."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Save the current directory
|
||||||
|
CUR_DIR=$(pwd)
|
||||||
|
|
||||||
|
# Get system architecture
|
||||||
|
ARCH=$(uname -m)
|
||||||
|
|
||||||
|
# Change to the temporary directory
|
||||||
|
cd /tmp
|
||||||
|
|
||||||
|
# Download the latest version of the package for the system architecture
|
||||||
|
# Exit if the download fails
|
||||||
|
echo "Downloading gh-wh-handler..."
|
||||||
|
curl -fsSL https://cdn.tiagorg.pt/gh-wh-handler/gh-wh-handler.${ARCH}.latest.tar.gz -o gh-wh-handler.tar.gz || { echo "Download failed."; exit 1; }
|
||||||
|
|
||||||
|
# Extract the package
|
||||||
|
echo "Extracting gh-wh-handler..."
|
||||||
|
tar -xzf gh-wh-handler.tar.gz || { echo "Extraction failed."; exit 1; }
|
||||||
|
|
||||||
|
# Change to the extracted directory
|
||||||
|
cd gh-wh-handler
|
||||||
|
|
||||||
|
# Install the package
|
||||||
|
echo "Installing gh-wh-handler..."
|
||||||
|
|
||||||
|
# Create service directory
|
||||||
|
echo "Creating service directory..."
|
||||||
|
mkdir -p /services/gh-wh-handler
|
||||||
|
mkdir -p /services/gh-wh-handler/logs
|
||||||
|
|
||||||
|
# Copy the binary and configuration file to the service directory
|
||||||
|
echo "Copying files..."
|
||||||
|
cp "gh-wh-handler.${ARCH}" /services/gh-wh-handler/
|
||||||
|
cp "config.json" /services/gh-wh-handler/
|
||||||
|
|
||||||
|
# Create a symbolic link to the binary in /usr/bin
|
||||||
|
echo "Creating symbolic link..."
|
||||||
|
ln -sf /services/gh-wh-handler/gh-wh-handler.${ARCH} /usr/bin/gh-wh-handler
|
||||||
|
|
||||||
|
# Copy the service file to the systemd directory
|
||||||
|
echo "Copying service file..."
|
||||||
|
cp "gh-wh-handler.service" /etc/systemd/system/
|
||||||
|
|
||||||
|
# Reload systemd
|
||||||
|
echo "Reloading systemd..."
|
||||||
|
systemctl daemon-reload
|
||||||
|
|
||||||
|
# Enable and start the service
|
||||||
|
echo "Enabling and starting service..."
|
||||||
|
systemctl enable gh-wh-handler
|
||||||
|
systemctl start gh-wh-handler
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
echo "Cleaning up..."
|
||||||
|
cd /tmp
|
||||||
|
rm -rf gh-wh-handler
|
||||||
|
rm gh-wh-handler.tar.gz
|
||||||
|
|
||||||
|
# Change back to the original directory
|
||||||
|
cd $CUR_DIR
|
||||||
|
echo "Installation complete."
|
Loading…
Reference in New Issue