udpate
This commit is contained in:
@@ -29,34 +29,21 @@ sudo apt update && sudo apt install -y git gh apache2 sqlite3 php php-sqlite3 py
|
||||
info "Installing Python libraries..."
|
||||
sudo pip3 install pyserial requests RPi.GPIO adafruit-circuitpython-bme280 crcmod psutil gpiozero ntplib pytz --break-system-packages || error "Failed to install Python libraries."
|
||||
|
||||
# Ask user if they want to set up SSH keys
|
||||
read -p "Do you want to set up an SSH key for /var/www? (y/n): " answer
|
||||
answer=${answer,,} # Convert to lowercase
|
||||
|
||||
if [[ "$answer" == "y" ]]; then
|
||||
info "Setting up SSH keys..."
|
||||
|
||||
sudo mkdir -p /var/www/.ssh
|
||||
sudo chmod 700 /var/www/.ssh
|
||||
|
||||
if [[ ! -f /var/www/.ssh/id_rsa ]]; then
|
||||
sudo ssh-keygen -t rsa -b 4096 -f /var/www/.ssh/id_rsa -N ""
|
||||
success "SSH key generated successfully."
|
||||
else
|
||||
warning "SSH key already exists. Skipping key generation."
|
||||
fi
|
||||
|
||||
sudo ssh-copy-id -i /var/www/.ssh/id_rsa.pub -p 50221 airlab_server1@aircarto.fr || warning "Failed to copy SSH key. Please check the server connection."
|
||||
|
||||
success "SSH setup complete!"
|
||||
else
|
||||
warning "Skipping SSH key setup."
|
||||
fi
|
||||
|
||||
# Clone the repository (check if it exists first)
|
||||
REPO_DIR="/var/www/nebuleair_pro_4g"
|
||||
if [[ -d "$REPO_DIR" ]]; then
|
||||
warning "Repository already exists. Skipping clone."
|
||||
warning "Repository already exists. Will update instead of clone."
|
||||
# Save current directory
|
||||
local current_dir=$(pwd)
|
||||
# Navigate to repository directory
|
||||
cd "$REPO_DIR"
|
||||
# Stash any local changes
|
||||
sudo git stash || warning "Failed to stash local changes"
|
||||
# Pull latest changes
|
||||
sudo git pull || error "Failed to pull latest changes"
|
||||
# Return to original directory
|
||||
cd "$current_dir"
|
||||
success "Repository updated successfully!"
|
||||
else
|
||||
info "Cloning the NebuleAir Pro 4G repository..."
|
||||
sudo git clone http://gitea.aircarto.fr/PaulVua/nebuleair_pro_4g.git "$REPO_DIR" || error "Failed to clone repository."
|
||||
@@ -98,6 +85,7 @@ if [[ -f "$REPO_DIR/sqlite/set_config.py" ]]; then
|
||||
else
|
||||
warning "Database creation script not found."
|
||||
fi
|
||||
|
||||
# Configure Apache
|
||||
info "Configuring Apache..."
|
||||
APACHE_CONF="/etc/apache2/sites-available/000-default.conf"
|
||||
@@ -140,7 +128,6 @@ success "I2C ports enabled."
|
||||
info "Creates sqlites databases..."
|
||||
/usr/bin/python3 /var/www/nebuleair_pro_4g/sqlite/create_db.py
|
||||
|
||||
|
||||
# Completion message
|
||||
success "Setup completed successfully!"
|
||||
info "System will reboot in 5 seconds..."
|
||||
|
||||
Reference in New Issue
Block a user