thirdculture/scripts/add_person.sh

59 lines
1.4 KiB
Bash
Raw Permalink Normal View History

2024-11-11 14:52:00 -05:00
#!/bin/bash
# Ensure the script is run with exactly two arguments
if [ $# -ne 2 ]; then
echo "Usage: $0 <path> <name>"
exit 1
fi
# Define variables
path="$1"
name="$2"
# Create the folder structure
mkdir -p "$path/$name/_werc" "$path/$name/blog/_werc"
# Create the first config file (not under blog)
cat > "$path/$name/_werc/config" <<EOF
conf_enable_wiki
conf_enable_cssedit $name
2024-11-18 01:53:38 -05:00
wiki_editors_groups=$name
2024-11-11 14:52:00 -05:00
css_file='_werc/style.css'
EOF
# Create the second config file (under blog)
cat > "$path/$name/blog/_werc/config" <<EOF
conf_enable_wiki
conf_enable_blog
conf_blog_only_pull=0
conf_blog_editors=$name
2024-11-18 02:19:06 -05:00
wiki_editors_groups=$name
blogTitle=''
2024-11-11 14:52:00 -05:00
blogDesc=''
EOF
# Create the style.css file
echo "/* Put custom styles here */" > "$path/$name/_werc/style.css"
2024-11-17 19:38:38 -05:00
# Update index.html
index_file="$path/index.html"
if [ -f "$index_file" ]; then
awk -v name="$name" '
{
print
if ($0 ~ /<!-- BUTTONS -->/) {
print " <div class=\"grid-item\">"
print " <a href=\"/" name "/\"><img src=\"/_werc/pub/img/but/" name ".gif\" alt=\"" name "\" /></a>"
print " </div>"
print ""
}
}' "$index_file" > "${index_file}.tmp" && mv "${index_file}.tmp" "$index_file"
echo "Updated index.html with new user entry"
else
echo "Warning: index.html not found at $index_file"
fi
2024-11-11 14:52:00 -05:00
# Output a success message
echo "Folder structure created successfully at $path/$name"