Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker installation (with Python3 support) #256

Open
mfedatto opened this issue Feb 23, 2023 · 1 comment
Open

Docker installation (with Python3 support) #256

mfedatto opened this issue Feb 23, 2023 · 1 comment

Comments

@mfedatto
Copy link

I'm working on an automated setup, and for the whitelist to work properly on Pi-hole on Docker, I need an entrypoint script. Since a script is needed, I'm working on installing python, checking if the repo was already cloned, if not, cloning it, and if so, pulling it, then proceeding to invoke the whitelist.py and add it to crontab. But the script I managed to reach is facing a fatal error:

fatal: destination path 'whitelist' already exists and is not an empty directory.

My init.sh as entrypoint:

apt install python3 -y
cd

# The name of the directory to check/create
dir_name="whitelist"

# The Git repository URL to clone/pull from
repo_url="https://github.com/anudeepND/whitelist.git"

# Check if the directory already exists
if [ -d "$dir_name" ]; then
  echo "Directory '$dir_name' already exists. Doing a 'git pull'..."
  cd "$dir_name"
  git pull
else
  echo "Directory '$dir_name' does not exist. Doing a 'git clone'..."
  git clone "$repo_url" "$dir_name"
fi

python3 whitelist/scripts/whitelist.py

cat /etc/crontab >> tmp_crontab
echo "0 1 * * */7     root    /root/whitelist/scripts/whitelist.py" >> tmp_crontab

cp tmp_crontab /etc/crontab
rm tmp_crontab

I'm willing to send a PR with the working instructions once I get it working properly.

@LeonardoMor
Copy link

The cd after installing python3, cd to where? I'm not sure how you plan on using this. Will you have this init.sh on the machine that runs docker and then add it to crontab?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants