-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·124 lines (107 loc) · 3.48 KB
/
install.sh
File metadata and controls
executable file
·124 lines (107 loc) · 3.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/bash
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
clear
echo -e "${YELLOW}Starting installation...${NC}"
# Check if PHP is installed
if ! command -v php &> /dev/null; then
echo -e "${RED}PHP is not installed. Please install PHP and try again.${NC}"
exit 1
fi
# Kill any existing process on port 8007
echo "Checking for existing processes on port 8007..."
if command -v lsof >/dev/null 2>&1; then
PORT_PID=$(lsof -ti:8007)
if [ ! -z "$PORT_PID" ]; then
echo "Killing process using port 8007..."
kill -9 $PORT_PID
sleep 1
fi
else
# Fallback to pkill if lsof is not available
if pgrep -f "php -S.*:8007" > /dev/null; then
echo "Killing existing PHP server on port 8007..."
pkill -f "php -S.*:8007"
sleep 1
fi
fi
# Create necessary directories if they don't exist
echo "Creating necessary directories..."
mkdir -p uploads/images
mkdir -p uploads/documents
mkdir -p uploads/other
# Set proper permissions
echo "Setting permissions..."
chmod -R 755 .
chmod -R 777 uploads
find . -type f -name "*.php" -exec chmod 644 {} \;
find . -type f -name "*.sh" -exec chmod 755 {} \;
# Copy .env.example to .env if it doesn't exist
if [ ! -f .env ]; then
echo "Creating .env file..."
cp .env.example .env
if [ $? -eq 0 ]; then
echo -e "${GREEN}Created .env file${NC}"
else
echo -e "${RED}Failed to create .env file${NC}"
exit 1
fi
fi
# Copy admin/.env.example to admin/.env if it doesn't exist
#if [ ! -f admin/.env ]; then
# echo "Creating admin/.env file..."
# cp admin/.env.example admin/.env
# if [ $? -eq 0 ]; then
# echo -e "${GREEN}Created admin/.env file${NC}"
# else
# echo -e "${RED}Failed to create admin/.env file${NC}"
# exit 1
# fi
#fi
# ADMIN: Load Variables
#source admin/.env
#rm -f admin/*.sqlite
#
## Run the admin database installation
#echo "Running admin database installation..."
#ADMIN_INSTALL_RESULT=$(php -d display_errors=1 admin/install.php 2>&1)
#
## Check if the admin installation was successful by looking for success:true and no error messages
#if echo "$ADMIN_INSTALL_RESULT" | grep -q '"success": *true' && ! echo "$ADMIN_INSTALL_RESULT" | grep -q "PHP Warning\|PHP Notice\|PHP Error"; then
# echo -e "${GREEN}Admin database installation completed successfully!${NC}"
#
# # Create admin user if it doesn't exist
# echo "Creating admin users..."
# php admin/scripts/create_user.php
#
# echo -e "${GREEN}Installation completed!${NC}"
# echo -e "${YELLOW}Please ensure your web server has proper permissions to write to the uploads directory.${NC}"
# echo -e "${YELLOW}You can now log in to the admin panel with the default credentials:${NC}"
# echo "Username: admin"
# echo "Password: admin123"
# echo -e "${RED}IMPORTANT: Please change the default password after your first login!${NC}"
#
#
#else
# echo -e "${RED}Admin database installation failed:${NC}"
# echo "$ADMIN_INSTALL_RESULT"
# exit 1
#fi
rm -rf logs/*.log
source .env
# USER: Remove existing databases
rm -f database.sqlite
# Run the main database installation
echo "Running main database installation..."
php install.php
# Load Variables
HOSTNAME=${HOSTNAME:-localhost}
PORT=${PORT:-8007}
# Local PHP setup
echo -e "\n${YELLOW}Starting PHP development server...${NC}"
echo -e "You can access the application at: http://${HOSTNAME}:${PORT}"
echo -e "Press Ctrl+C to stop the server"
php -S ${HOSTNAME}:${PORT}