39 lines
864 B
Bash
39 lines
864 B
Bash
|
#!/bin/bash
|
||
|
|
||
|
# Function to create config.cfg based on user input
|
||
|
create_config_file() {
|
||
|
cat <<EOF > config.cfg
|
||
|
[options]
|
||
|
database="$1"
|
||
|
|
||
|
[mysql]
|
||
|
mysqlconnect_path="/var/config/mysqlconnect.php"
|
||
|
host="localhost"
|
||
|
username="dbUser"
|
||
|
database="dbName"
|
||
|
password="dbPassword"
|
||
|
|
||
|
[sqlite]
|
||
|
password="CHANGE_ME!"
|
||
|
EOF
|
||
|
}
|
||
|
|
||
|
# Prompt user for database type
|
||
|
echo "Do you want to use sqlite or mysql? (default: sqlite)"
|
||
|
read -t 5 -p "Enter your choice: " db_choice
|
||
|
|
||
|
# Set default value if no input is given
|
||
|
db_choice=${db_choice:-sqlite}
|
||
|
|
||
|
# Create config.cfg based on user input
|
||
|
create_config_file $db_choice
|
||
|
|
||
|
# Create directory for mysql configuration
|
||
|
if [ "$db_choice" = "mysql" ]; then
|
||
|
mkdir -p /var/config
|
||
|
cp example.mysqlconnect.php /var/config/mysqlconnect.php
|
||
|
chmod 755 /var/config/mysqlconnect.php
|
||
|
fi
|
||
|
|
||
|
echo "Setup complete. Configuration saved in config.cfg."
|