This repository has been archived on 2024-04-19. You can view files and clone it, but cannot push or open issues or pull requests.
FREAX/reload.sh
2022-07-18 19:33:40 +02:00

56 lines
1.6 KiB
Bash
Executable file

#!/bin/bash
# Enviroment variables
## RELOADSH_OUTPUT
### Configures the output folder
### Example: RELOADSH_OUTPUT=~/.local/share/ccemux/computer
#RELOADSH_OUTPUT=~/.local/share/multimc/instances/MultiStar/.minecraft/saves/Weihnachten/computercraft/computer
RELOADSH_OUTPUT=~/.local/share/ccemux/computer
## RELOADSH_OUTPUT_LASTDIR
### Configures the output folder's last directory
### Example: RELOADSH_OUTPUT_LASTDIR=0/
RELOADSH_OUTPUT_LASTDIR=0/
## RELOADSH_INPUT
### Configures the input folder
### Should not be touched
### Example: RELOADSH_INPUT=$(pwd)
RELOADSH_INPUT=$(pwd)
## RELOADSH_NOLOOP
### Configures if a loop is
### being used or not.
### Example: RELOADSH_NOLOOP=true
#RELOADSH_NOLOOP=false
# Code
if [ ! -d "$RELOADSH_INPUT" ]; then
echo "$RELOADSH_INPUT (\$RELOADSH_INPUT) is not a directory or does not exist."
exit 1
fi
if [ ! -d "$RELOADSH_OUTPUT" ]; then
echo "$RELOADSH_OUTPUT (\$RELOADSH_OUTPUT) is not a directory or does not exist."
exit 1
fi
function reloadOS() {
echo -n "Reloading FREAX... "
if [ ! -d "$RELOADSH_INPUT" ]; then
echo -e "fail.\n$RELOADSH_INPUT (\$RELOADSH_INPUT) is not a directory or does not exist."
exit 1
fi
if [ ! -d "$RELOADSH_OUTPUT" ]; then
echo -e "fail.\n$RELOADSH_OUTPUT (\$RELOADSH_OUTPUT) is not a directory or does not exist."
exit 1
fi
/bin/rm -rf "$RELOADSH_OUTPUT/$RELOADSH_OUTPUT_LASTDIR"
/bin/cp -r "$RELOADSH_INPUT" "$RELOADSH_OUTPUT/$RELOADSH_OUTPUT_LASTDIR"
echo "done."
}
if [ "$RELOADSH_NOLOOP" == "true" ]; then
reloadOS
elif [ "$RELOADSH_NOLOOP" == "false" ]; then
while true; do
echo -en "\nPress [enter] to reload"
read -rs
echo ""
reloadOS
done
fi