mirror of
https://github.com/10h30/kazewp.git
synced 2026-05-12 15:21:20 +09:00
Update README and restructure code
This commit is contained in:
@@ -44,8 +44,8 @@ Ensure you have the following installed:
|
||||
|
||||
## **Usage**
|
||||
|
||||
```bash
|
||||
|
||||
```
|
||||
|
||||
./kazewp.sh list - List all installed WordPress sites"
|
||||
./kazewp.sh install <domain> - Install a new WordPress site"
|
||||
./kazewp.sh stop <domain> - Stop running WordPress sites"
|
||||
|
||||
@@ -12,7 +12,7 @@ source "${SCRIPT_DIR}/lib/docker.sh"
|
||||
source "${SCRIPT_DIR}/lib/caddy.sh"
|
||||
source "${SCRIPT_DIR}/lib/wordpress.sh"
|
||||
source "${SCRIPT_DIR}/lib/menu.sh"
|
||||
#source "${SCRIPT_DIR}/lib/log.sh"
|
||||
source "${SCRIPT_DIR}/lib/log.sh"
|
||||
|
||||
|
||||
# Check if Docker is installed
|
||||
|
||||
+1
-1
@@ -102,7 +102,7 @@ setup_directories() {
|
||||
mkdir -p "${CADDY_DIR}/caddy_config"
|
||||
|
||||
if [ ! -f "${CADDY_DIR}/Caddyfile" ]; then
|
||||
echo "Creating initial Caddy configuration..."
|
||||
#echo "Creating initial Caddy configuration..."
|
||||
create_caddy_docker_compose
|
||||
fi
|
||||
}
|
||||
@@ -43,6 +43,7 @@ BG_PURPLE='\033[45m'
|
||||
BG_CYAN='\033[46m'
|
||||
BG_WHITE='\033[47m'
|
||||
|
||||
|
||||
# Styling Helper Functions
|
||||
print_header() {
|
||||
local text="$1"
|
||||
|
||||
+6
-17
@@ -13,22 +13,11 @@ if [ ! -w "$LOG_FILE" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Function to add timestamp to log file
|
||||
add_timestamp() {
|
||||
echo -e "\n========== $(date '+%Y-%m-%d %H:%M:%S') ==========" >> "$LOG_FILE"
|
||||
# Function to strip ANSI color codes
|
||||
strip_colors() {
|
||||
sed -r "s/\x1B\[([0-9]{1,3}(;[0-9]{1,2})?)?[mGK]//g"
|
||||
}
|
||||
|
||||
# Save original file descriptors
|
||||
exec 3>&1
|
||||
exec 4>&2
|
||||
|
||||
# Add timestamp to log file
|
||||
add_timestamp
|
||||
|
||||
# Setup logging while preserving read -p functionality:
|
||||
# Use process substitution for logging
|
||||
exec 1> >(tee >(sed 's/\x1B\[[0-9;]*[JKmsu]//g' >> "$LOG_FILE"))
|
||||
exec 2> >(tee >(sed 's/\x1B\[[0-9;]*[JKmsu]//g' >> "$LOG_FILE"))
|
||||
|
||||
# Restore original stdout for read commands
|
||||
export BASH_READ_FD=3
|
||||
# Redirect all output to both the terminal and the log file (without colors)
|
||||
exec > >(tee -a >(strip_colors >> "$LOG_FILE"))
|
||||
exec 2> >(tee -a >(strip_colors >> "$LOG_FILE") >&2)
|
||||
+20
-16
@@ -14,32 +14,36 @@ show_interactive_menu() {
|
||||
print_info " $0 delete <domain> - Delete a WordPress site"
|
||||
print_info " $0 delete all - Delete everything"
|
||||
|
||||
# First check if any sites exist
|
||||
if [ ! -d "$WORDPRESS_DIR" ] || [ -z "$(ls -A "$WORDPRESS_DIR" 2>/dev/null)" ]; then
|
||||
print_warning "No WordPress sites installed yet."
|
||||
show_action_menu "brand-new"
|
||||
return
|
||||
fi
|
||||
|
||||
# Get and display existing sites
|
||||
local -a sites=()
|
||||
local i=1
|
||||
|
||||
print_subheader "Installed WordPress Sites"
|
||||
while IFS= read -r site; do
|
||||
if [ -f "$site/compose.yaml" ]; then
|
||||
sites+=("$(basename "$site")")
|
||||
domain=$(basename "$site")
|
||||
status=$(get_site_status "$site/compose.yaml")
|
||||
print_menu_item "$i" "$domain" "$status"
|
||||
((i++))
|
||||
fi
|
||||
done < <(find "$WORDPRESS_DIR" -mindepth 1 -maxdepth 1 -type d | sort)
|
||||
|
||||
# First check if any sites exist
|
||||
if [ ! -d "$WORDPRESS_DIR" ] || [ -z "$(ls -A "$WORDPRESS_DIR" 2>/dev/null)" ]; then
|
||||
print_warning "No WordPress sites installed yet."
|
||||
#show_action_menu "brand-new"
|
||||
#return
|
||||
else
|
||||
while IFS= read -r site; do
|
||||
if [ -f "$site/compose.yaml" ]; then
|
||||
sites+=("$(basename "$site")")
|
||||
domain=$(basename "$site")
|
||||
status=$(get_site_status "$site/compose.yaml")
|
||||
print_menu_item "$i" "$domain" "$status"
|
||||
((i++))
|
||||
fi
|
||||
done < <(find "$WORDPRESS_DIR" -mindepth 1 -maxdepth 1 -type d | sort)
|
||||
fi
|
||||
|
||||
print_subheader "Available Actions"
|
||||
echo -e "${BWHITE}Select an option:${NC}"
|
||||
print_menu_action "n" "Install new WordPress site"
|
||||
print_menu_action "m" "Manage multiple sites"
|
||||
if [ -d "$WORDPRESS_DIR" ] && [ -n "$(find "$WORDPRESS_DIR" -mindepth 1 -type d 2>/dev/null)" ]; then
|
||||
print_menu_action "m" "Manage multiple sites"
|
||||
fi
|
||||
print_menu_action "q" "Quit"
|
||||
print_separator
|
||||
|
||||
|
||||
Reference in New Issue
Block a user