new: [add] init commit, elab-update, elab-manage-install & scripts

This commit is contained in:
default
2024-05-30 17:42:32 +02:00
commit 4767e76060
6 changed files with 152 additions and 0 deletions

20
bin/elab-manage-install Executable file
View File

@@ -0,0 +1,20 @@
#!/bin/bash
# Get the directory where the script resides
SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
# TODO: ${##*/}
# Define the destination directory where the elab-update symbolic link will be created
DEST_DIR="/usr/local/bin/"
# Check if the elab-update script exists in the source directory
if [ ! -f "$SOURCE_DIR/elab-update" ]; then
echo "Error: elab-update script not found in the source directory."
exit 1
fi
# Create a symbolic link to the elab-update script in the destination directory
echo "Creating symbolic link to elab-update script in $DEST_DIR..."
sudo ln -sf "$SOURCE_DIR/elab-update" "$DEST_DIR" || { echo "Error: Unable to create symbolic link."; exit 1; }
echo "elab-update command has been successfully installed as a symbolic link."

37
bin/elab-update Executable file
View File

@@ -0,0 +1,37 @@
#!/bin/bash
# Define the repository path
REPO_PATH="/opt/apps/elab-manage"
# Function to update the git repository
update_repo() {
echo "Updating the git repository..."
cd "$REPO_PATH" || {
echo "Error: Unable to find the repository at $REPO_PATH";
exit 1;
}
git pull -r || {
echo "Error: Unable to update the repository";
exit 1;
}
}
# Function to update symbolic links
update_symlinks() {
echo "Updating symbolic links for cron.daily..."
# Update or add new symbolic links for cron.daily and cron.hourly
for dir in "cron."{daily,hourly}; do
find -L /etc/$dir -maxdepth 1 -type l -ilname $REPO_PATH/etc/$dir\* -delete
ln -sf $REPO_PATH/etc/$dir/* /etc/$dir
done
echo "Symbolic links have been successfully updated."
}
# Update the git repository and symbolic links
update_repo
update_symlinks
echo "Elabore Update complete."