- Registriert
- 17. Februar 2008
- Beiträge
- 14.336
- Lösungen
- 3
- Reaktionspunkte
- 9.777
- Punkte
- 1.093
Mal testen.
Als sudo auf dem Host.
Keine Ahnung ob`s klappt.
Als sudo auf dem Host.
Bash:
#!/bin/bash
echo "Installing pip on Raspberry Pi..."
sudo apt update
sudo apt install -y python3-pip
echo "Enter your Docker container name:"
read CONTAINER_NAME
# Check if the container exists
docker ps -a --format "{{.Names}}" | grep -wq "$CONTAINER_NAME"
if [ $? -ne 0 ]; then
echo "Error: Container '$CONTAINER_NAME' does not exist."
exit 1
fi
echo "Updating package lists and installing required packages inside container..."
docker exec -it "$CONTAINER_NAME" bash -c "apt-get update && \
apt-get install -y sudo cron python3 python3-pip"
echo "Starting cron service..."
docker exec -it "$CONTAINER_NAME" bash -c "service cron start && systemctl enable cron"
echo "Configuring sudoers for www-data..."
docker exec -it "$CONTAINER_NAME" bash -c "echo 'www-data ALL=(ALL) NOPASSWD:ALL' > /etc/sudoers.d/www-data && \
chmod 440 /etc/sudoers.d/www-data && \
chown -R www-data:www-data /var/spool/cron && \
chmod -R 755 /var/spool/cron && \
(pgrep cron || cron)"
echo "Installing Python libraries inside container..."
docker exec -it "$CONTAINER_NAME" bash -c "pip3 install --upgrade pip && pip3 install requests aiohttp tqdm"
echo "Checking for installed PHP version..."
PHP_VERSION=$(docker exec -it "$CONTAINER_NAME" bash -c "php -v | grep -oP '(?<=PHP )\d+\.\d+'" | tr -d '\r')
if [[ -n "$PHP_VERSION" ]]; then
PHP_INI_PATH="/etc/php/$PHP_VERSION/apache2/php.ini"
echo "Modifying PHP settings in $PHP_INI_PATH..."
docker exec -it "$CONTAINER_NAME" bash -c "sed -i -e 's/^post_max_size = [0-9]\+M/post_max_size = 100M/' -e 's/^upload_max_filesize = [0-9]\+M/upload_max_filesize = 100M/' $PHP_INI_PATH"
else
echo "PHP is not installed in the container."
fi
echo "Setup completed for container: $CONTAINER_NAME"
Keine Ahnung ob`s klappt.