essb/cf-php

Handle Zones, DSN records and Tunnels on Cloudflare from the commandline.

0.4.02 2024-07-16 05:36 UTC

This package is auto-updated.

Last update: 2024-11-16 06:18:22 UTC


README

A simple command-line application to interact with cloudflare from the command line.

With it you can:

  • List Accounts
  • List Zones
  • List, Add, Delete, Update DNS Records per zone
  • List, Add, Delete Tunnels
  • Purge entire cache
  • Purge cache (by URL)

Pre-requsites

PHP >= 7

Composer

Install

via gitea (recommened)

Clone to a nice place

cd ~ && git clone https://git.sbcloud.cc/sb/cf-php.git && cd cf-php

Bestow execution privileges & move to /usr/bin:

chmod +x cf-php && mv cf-php.php /usr/bin/cf-php

Configure

The first time you run the application (as root) it will ask you to provide a Cloudflare email and token. It will then create a cf-php.config.

Afterward, you can edit it any ol' time you like with your favourite editor vim.

Security note

Since your cloudflare credentials are stored in plain text, the file permissions are set to 0600 and owned by root, so you must run cf-php as the root user, or using a sudo like command.

Optionally, you may change permissions of /etc/cf-php.config to suit your needs and concerns. Just run as root the first time to generate the configuration file, then change permissions manually.

Example:

 chmod 0660 /etc/cf-php.config
 chown manager:wheel /etc/cf-php.config

Usage

cf-php list zones
cf-php list accounts
cf-php list tunnels

cf-php list dns
cf-php list dns [zone id]

cf-php add dns
cf-php add dns [zone id]

cf-php update dns
cf-php update dns [dns id]

cf-php delete dns
cf-php delete dns [dns id]

cf-php add tunnel [tunnel id]
cf-php delete tunnel [tunnel id]

cf-php purge cache

cf-php (shows usage screen)

License

Copyright 2024 Sean Boyer

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see https://www.gnu.org/licenses/.

TODO

  • Add default zone selection / single zone
  • Purge multiple URLs
  • List tunnels
  • Delete tunnels
  • Purge everything