Latest lex_scan, script to copy to SME11, program to count references
This commit is contained in:
87
copylex.sh
Executable file
87
copylex.sh
Executable file
@@ -0,0 +1,87 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Usage/help function
|
||||
usage() {
|
||||
echo "Usage: $0 ModuleName"
|
||||
echo " ModuleName must start with a capital letter and match a directory under:"
|
||||
echo " ~/SME11/usr/share/smanager/lib/SrvMngr/I18N/Modules/"
|
||||
echo "Example: $0 Useraccounts"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Check parameter
|
||||
if [ -z "$1" ]; then
|
||||
echo "Error: No module name provided."
|
||||
usage
|
||||
fi
|
||||
|
||||
MODULE_NAME="$1"
|
||||
|
||||
# Check if parameter starts with a capital letter
|
||||
if [[ ! "$MODULE_NAME" =~ ^[A-Z] ]]; then
|
||||
echo "Error: Module name must start with a capital letter."
|
||||
usage
|
||||
fi
|
||||
|
||||
# Check if directory exists
|
||||
SRC_DIR=~/SME11/usr/share/smanager/lib/SrvMngr/I18N/Modules
|
||||
MODULE_DIR="${SRC_DIR}/${MODULE_NAME}"
|
||||
if [ ! -d "$MODULE_DIR" ]; then
|
||||
echo "Error: Directory '${MODULE_DIR}' does not exist."
|
||||
usage
|
||||
fi
|
||||
|
||||
# Convert to lowercase for filenames
|
||||
MODULE_NAME_LC=$(echo "$MODULE_NAME" | tr '[:upper:]' '[:lower:]')
|
||||
|
||||
# Paths
|
||||
LEX_FILE="${MODULE_DIR}/${MODULE_NAME_LC}_en.lex"
|
||||
BAK_FILE="${LEX_FILE}.bak"
|
||||
NEW_LEX_FILE="output/${MODULE_NAME}/${MODULE_NAME_LC}_en.lex.new1"
|
||||
|
||||
GENERAL_LEX_FILE="${SRC_DIR}/General/general_en.lex"
|
||||
GENERAL_BAK_FILE="${GENERAL_LEX_FILE}.bak"
|
||||
GENERAL_NEW_LEX_FILE="output/General/general_en.lex.new1"
|
||||
|
||||
# Move to backup only if .bak does not exist (module file)
|
||||
if [ ! -f "$BAK_FILE" ]; then
|
||||
mv -v "$LEX_FILE" "$BAK_FILE"
|
||||
fi
|
||||
|
||||
# Move to backup only if .bak does not exist (general file)
|
||||
if [ ! -f "$GENERAL_BAK_FILE" ]; then
|
||||
mv -v "$GENERAL_LEX_FILE" "$GENERAL_BAK_FILE"
|
||||
fi
|
||||
|
||||
# Copy new lex files
|
||||
cp -v "$NEW_LEX_FILE" "$LEX_FILE"
|
||||
cp -v "$GENERAL_NEW_LEX_FILE" "$GENERAL_LEX_FILE"
|
||||
|
||||
|
||||
# Copy template files from output/<ModuleName>/<subdir>
|
||||
TEMPLATE_SRC_PARENT="output/${MODULE_NAME}"
|
||||
|
||||
TEMPLATE_TARGET_BASE=~/SME11/usr/share/smanager/themes
|
||||
|
||||
if [ -d "$TEMPLATE_SRC_PARENT" ]; then
|
||||
for SUBDIR in "$TEMPLATE_SRC_PARENT"/*/; do
|
||||
[ ! -d "$SUBDIR" ] && continue # skip if no subdirs
|
||||
SUBDIR_NAME=$(basename "$SUBDIR")
|
||||
find "$SUBDIR" -type f | while read -r FILE; do
|
||||
BASENAME=$(basename "$FILE")
|
||||
# Remove the first .new in the name (if any), e.g., foo.html.new.ep => foo.html.ep
|
||||
NEWNAME="${BASENAME/.new/}"
|
||||
if [[ "$BASENAME" == _* ]]; then
|
||||
DEST="$TEMPLATE_TARGET_BASE/$SUBDIR_NAME/templates/partials/"
|
||||
else
|
||||
DEST="$TEMPLATE_TARGET_BASE/$SUBDIR_NAME/templates/"
|
||||
fi
|
||||
mkdir -p "$DEST"
|
||||
cp -v "$FILE" "$DEST/$NEWNAME"
|
||||
done
|
||||
done
|
||||
fi
|
||||
|
||||
|
||||
|
||||
ssh -p 1234 root@SME11.thereadclan.me.uk 'signal-event smanager-refresh'
|
Reference in New Issue
Block a user