diff --git a/README.md b/README.md index 9c3a374..24fb1ff 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# infinipaste +# tclip [![status: experimental](https://img.shields.io/badge/status-experimental-blue)](https://tailscale.com/kb/1167/release-stages/#experimental) @@ -11,8 +11,8 @@ number of pastes. 2. Enable flakes 3. `nix develop` -You can then test your changes to infinipaste by running `go run -./cmd/web` or `go run ./cmd/infinipaste` as appropriate. +You can then test your changes to tclip by running `go run +./cmd/web` or `go run ./cmd/tclip` as appropriate. ## Building for prod @@ -34,7 +34,7 @@ nix build .#portable-service ## Deploying -There are several options you can take to deploy infinipaste. The most +There are several options you can take to deploy tclip. The most basic deployment method is to use [fly.io](https://fly.io), but we offer a few options so that you can make the decision that is right for you. @@ -44,7 +44,7 @@ for you. In order to deploy this service, you will need to get an authkey from [the admin panel](https://login.tailscale.com/admin/settings/keys). It is a good idea to associate this with the tag `tag:service` or its own -`tag:infinipaste`. Please also do not set the `ephemeral` tag as that +`tag:tclip`. Please also do not set the `ephemeral` tag as that will destroy the node when the service shuts down. Your authkey should start with `tskey-auth`. @@ -56,7 +56,7 @@ You will need to have ### fly.io In one of your infrastructure management GitHub repositories, create a -folder for infinipaste and then copy the following +folder for tclip and then copy the following [`fly.toml`](https://fly.io/docs/reference/configuration/) template into that folder. @@ -64,7 +64,7 @@ into that folder. app = "FLY_APP_NAME" [build] -image = "ghcr.io/tailscale-dev/infinipaste:main" +image = "ghcr.io/tailscale-dev/tclip:main" [deploy] strategy = "immediate" @@ -73,16 +73,16 @@ strategy = "immediate" DATA_DIR = "/data" [mounts] -source = "infinipaste_data" +source = "tclip_data" destination = "/data" ``` -Replace `FLY_APP_NAME` with a name such as `yourorg-infinipaste` and +Replace `FLY_APP_NAME` with a name such as `yourorg-tclip` and then run these commands with [the `flyctl` command](https://fly.io/docs/hands-on/install-flyctl/): ```console $ flyctl apps create FLY_APP_NAME -$ flyctl volumes create infinipaste_data +$ flyctl volumes create tclip_data $ flyctl secrets set TS_AUTHKEY= $ flyctl deploy ``` @@ -97,36 +97,36 @@ To run this service in Docker, run the following command: ``` docker run \ -d \ - -v /var/lib/infinipaste:/data \ + -v /var/lib/tclip:/data \ -e DATA_DIR=/data \ -e TS_AUTHKEY= \ - -n infinipaste \ + -n tclip \ --restart always \ - ghcr.io/tailscale-dev/infinipaste:main + ghcr.io/tailscale-dev/tclip:main ``` -Every so often you should pull a new version of infinipaste and +Every so often you should pull a new version of tclip and recreate the container: ``` -docker pull ghcr.io/tailscale-dev/infinipaste:main -docker rm -f infinipaste +docker pull ghcr.io/tailscale-dev/tclip:main +docker rm -f tclip ``` Then run the above command to recreate the container. #### Backups -Add the path `/var/lib/infinipaste` to your backup program of choice. +Add the path `/var/lib/tclip` to your backup program of choice. ### Systemd portable service systemd has a mechanism for [portable service](https://systemd.io/PORTABLE_SERVICES/) which are like Docker images mixed with systemd unit configurations. This allows you to -install infinipaste on any Linux distribution with systemd (and the +install tclip on any Linux distribution with systemd (and the `portablectl` command, install `systemd-container` to get this package -on Ubuntu). This lets you view infinipaste logs with `journalctl` and +on Ubuntu). This lets you view tclip logs with `journalctl` and manage it like any other systemd service. Download the portable service image yada yada TODO(Xe) fix this @@ -141,31 +141,31 @@ services: ```console $ portablectl list NAME TYPE RO CRTIME MTIME USAGE STATE -infinipaste_0.1.0-20230116 raw yes Mon 2023-01-16 16:49:58 UTC Mon 2023-01-16 16:53:59 UTC 14.8M detached +tclip_0.1.0-20230116 raw yes Mon 2023-01-16 16:49:58 UTC Mon 2023-01-16 16:53:59 UTC 14.8M detached ``` -Copy the name of the `infinipaste` service including the +Copy the name of the `tclip` service including the auto-generated version number to your clipboard (for example: -`infinipaste_0.1.0-20230116`) and pass that to `portablectl attach`: +`tclip_0.1.0-20230116`) and pass that to `portablectl attach`: ```console -$ sudo portablectl attach infinipaste_0.1.0-20230116 +$ sudo portablectl attach tclip_0.1.0-20230116 ``` -Next, create the folder `/etc/systemd/system/infinipaste.service.d` +Next, create the folder `/etc/systemd/system/tclip.service.d` and create the file `10-ts-auth-key.conf` in it with the following contents: ```systemd -# /etc/systemd/system/infinipaste.service.d/10-ts-auth-key.conf +# /etc/systemd/system/tclip.service.d/10-ts-auth-key.conf [Service] Environment=TS_AUTH_KEY= ``` -Finally, enable `infinipaste.service` and start it with `systemctl +Finally, enable `tclip.service` and start it with `systemctl enable --now`: ```console -$ sudo systemctl enable --now infinipaste.service +$ sudo systemctl enable --now tclip.service ``` Wait a moment for it to connect to Tailscale and then check on it with @@ -174,5 +174,5 @@ tailnet. #### Backups -Add the path `/var/lib/private/infinipaste` to your backup program of +Add the path `/var/lib/private/tclip` to your backup program of choice. diff --git a/cmd/web/tmpl/base.tmpl b/cmd/web/tmpl/base.tmpl index e7253ff..161cdb4 100644 --- a/cmd/web/tmpl/base.tmpl +++ b/cmd/web/tmpl/base.tmpl @@ -9,7 +9,7 @@
diff --git a/cmd/web/tmpl/help.tmpl b/cmd/web/tmpl/help.tmpl index f7c1422..4935e29 100644 --- a/cmd/web/tmpl/help.tmpl +++ b/cmd/web/tmpl/help.tmpl @@ -13,17 +13,17 @@

Command-line tool

-

You can pipe commands or paste files to the pastebin using the command infinipaste. You can install it by installing the Go compiler toolkit and then running this command:

+

You can pipe commands or paste files to the pastebin using the command tclip. You can install it by installing the Go compiler toolkit and then running this command:

-
go get github.com/tailscale-dev/infinipaste/cmd/infinipaste@main
+
go get github.com/tailscale-dev/tclip/cmd/tclip@main
-

Once it is installed, invoke it with the command infinipaste:

+

Once it is installed, invoke it with the command tclip:

-
infinipaste ./foo.txt
+
tclip ./foo.txt

and the program will print a URL that you can share with your team. You can also pipe the output from any command to it:

-
go test &2<1 | infinipaste -n go-test.txt
+
go test &2<1 | tclip -n go-test.txt

API

@@ -52,13 +52,13 @@

Emacs package

-

The default distribution of infinipaste ships with a package for GNU Emacs. This package will let you submit pastes from your editor. It requires the request package and exposes two interactive functions:

+

The default distribution of tclip ships with a package for GNU Emacs. This package will let you submit pastes from your editor. It requires the request package and exposes two interactive functions:

    -
  • M-x infinipaste-submit-region - submits the currently highlighted region to infinipaste
  • -
  • M-x infinipaste-submit-buffer - submits the contents of the current buffer to infinipaste
  • +
  • M-x tclip-submit-region - submits the currently highlighted region to tclip
  • +
  • M-x tclip-submit-buffer - submits the contents of the current buffer to tclip
-

You can download this package from the infinipaste repository. You can install it by using M-x package-install-file or by opening it in Emacs and running M-x package-install-from-buffer. Please be sure that request is installed.

+

You can download this package from the tclip repository. You can install it by using M-x package-install-file or by opening it in Emacs and running M-x package-install-from-buffer. Please be sure that request is installed.

{{template "footer" .}} diff --git a/contrib/infinipaste.el b/contrib/infinipaste.el deleted file mode 100644 index 6ec7e90..0000000 --- a/contrib/infinipaste.el +++ /dev/null @@ -1,81 +0,0 @@ -;;; infinipaste.el --- infinipaste client for Emacs -*- lexical-binding: t; -*- - -;; Copyright (C) -;; 2023 Tailscale, Inc. -;; Author: Xe Iaso -;; Maintainer: Xe Iaso -;; Created: 2023-01-13 -;; Version: 0.1 -;; Keywords: tailscale, pastebin, sharing -;; Homepage: https://github.com/tailscale-dev/infinipaste - -;;; Commentary: -;; -;; This uses request-el to make requests to your tailnet's infinipaste server. You -;; can install request-el with M-x package-install. -;; -;; This package requires that you have a infinipaste server set up. This package -;; reaches out to a infinipaste server over either plain HTTP, or HTTPS should you -;; configure the variable `infinipaste-server'. -;; -;; Usage: -;; -;; To submit the contents of the current buffer to infinipaste: -;; M-x infinipaste-submit-buffer -;; To submit the contents of the currently highlighted region to infinipaste: -;; M-x infinipaste-submit-region -;; -;; Customization: -;; -;; To customize the infinipaste server this package reaches out to: -;; M-x customize-group infinipaste -;; -;; You can customize the infinipaste server URL by changing the value of `infinipaste-server': -;; (setq infinipaste-server "https://paste.shark-harmonic.ts.net") - -;;; Code: - -(require 'request) - -(defgroup infinipaste nil - "Infinipaste server configuration." - :prefix "infinipaste-" - :group 'infinipaste) - -(defcustom infinipaste-server "http://paste" - "The server that is running infinipaste or a service with a compatible API to infinipaste. This should NOT end with a trailing slash." - :group 'infinipaste - :type 'string) - -(defun infinipaste--send-paste (fname content) - "Internal function that actually fires off the paste with name FNAME and content CONTENT to the infinipaste server." - (request (format "%s/api/post" infinipaste-server) - :type "POST" - :data `(("filename" . ,fname) - ("content" . ,content)) - :headers '(("Accept" . "text/plain")) - :timeout 60 - :success (cl-function - (lambda (&key response &allow-other-keys) - (message "%s" (request-response-data response)))))) - -(defun infinipaste-submit-buffer () - "Submits the entire current buffer to infinipaste." - (interactive) - (let ((fname (format "%s.%s" - (file-name-base (buffer-file-name)) - (file-name-extension (buffer-file-name)))) - (content (buffer-string))) - (infinipaste--send-paste fname content))) - -(defun infinipaste-submit-region () - "Submits the highlighted region to infinipaste." - (interactive) - (let ((fname (format "%s.%s" - (file-name-base (buffer-file-name)) - (file-name-extension (buffer-file-name)))) - (content (buffer-substring-no-properties (region-beginning) (region-end)))) - (infinipaste--send-paste fname content))) - -(provide 'infinipaste) -;;; infinipaste.el ends here diff --git a/contrib/tclip.el b/contrib/tclip.el new file mode 100644 index 0000000..2a501b4 --- /dev/null +++ b/contrib/tclip.el @@ -0,0 +1,81 @@ +;;; tclip.el --- tclip client for Emacs -*- lexical-binding: t; -*- + +;; Copyright (C) +;; 2023 Tailscale, Inc. +;; Author: Xe Iaso +;; Maintainer: Xe Iaso +;; Created: 2023-01-13 +;; Version: 0.1 +;; Keywords: tailscale, pastebin, sharing +;; Homepage: https://github.com/tailscale-dev/tclip + +;;; Commentary: +;; +;; This uses request-el to make requests to your tailnet's tclip server. You +;; can install request-el with M-x package-install. +;; +;; This package requires that you have a tclip server set up. This package +;; reaches out to a tclip server over either plain HTTP, or HTTPS should you +;; configure the variable `tclip-server'. +;; +;; Usage: +;; +;; To submit the contents of the current buffer to tclip: +;; M-x tclip-submit-buffer +;; To submit the contents of the currently highlighted region to tclip: +;; M-x tclip-submit-region +;; +;; Customization: +;; +;; To customize the tclip server this package reaches out to: +;; M-x customize-group tclip +;; +;; You can customize the tclip server URL by changing the value of `tclip-server': +;; (setq tclip-server "https://paste.shark-harmonic.ts.net") + +;;; Code: + +(require 'request) + +(defgroup tclip nil + "Tclip server configuration." + :prefix "tclip-" + :group 'tclip) + +(defcustom tclip-server "http://paste" + "The server that is running tclip or a service with a compatible API to tclip. This should NOT end with a trailing slash." + :group 'tclip + :type 'string) + +(defun tclip--send-paste (fname content) + "Internal function that actually fires off the paste with name FNAME and content CONTENT to the tclip server." + (request (format "%s/api/post" tclip-server) + :type "POST" + :data `(("filename" . ,fname) + ("content" . ,content)) + :headers '(("Accept" . "text/plain")) + :timeout 60 + :success (cl-function + (lambda (&key response &allow-other-keys) + (message "%s" (request-response-data response)))))) + +(defun tclip-submit-buffer () + "Submits the entire current buffer to tclip." + (interactive) + (let ((fname (format "%s.%s" + (file-name-base (buffer-file-name)) + (file-name-extension (buffer-file-name)))) + (content (buffer-string))) + (tclip--send-paste fname content))) + +(defun tclip-submit-region () + "Submits the highlighted region to tclip." + (interactive) + (let ((fname (format "%s.%s" + (file-name-base (buffer-file-name)) + (file-name-extension (buffer-file-name)))) + (content (buffer-substring-no-properties (region-beginning) (region-end)))) + (tclip--send-paste fname content))) + +(provide 'tclip) +;;; tclip.el ends here diff --git a/flake.nix b/flake.nix index d003e5b..f9d3f9e 100644 --- a/flake.nix +++ b/flake.nix @@ -28,23 +28,23 @@ in { packages = rec { web = pkgs.buildGoApplication { - pname = "infinipaste-web"; + pname = "tclip-web"; version = "0.1.0-${version}"; src = ./.; subPackages = "cmd/web"; modules = ./gomod2nix.toml; }; - infinipaste = pkgs.buildGoApplication { - pname = "infinipaste"; + tclip = pkgs.buildGoApplication { + pname = "tclip"; inherit (web) src version modules; - subPackages = "cmd/infinipaste"; + subPackages = "cmd/tclip"; CGO_ENABLED = "0"; }; docker = pkgs.dockerTools.buildLayeredImage { - name = "ghcr.io/tailscale-dev/infinipaste"; + name = "ghcr.io/tailscale-dev/tclip"; tag = "main"; config.Cmd = [ "${web}/bin/web" ]; contents = [ pkgs.cacert ]; @@ -52,15 +52,15 @@ portable-service = let web-service = pkgs.substituteAll { - name = "infinipaste.service"; - src = ./run/portable-service/infinipaste.service.in; + name = "tclip.service"; + src = ./run/portable-service/tclip.service.in; inherit web; }; in pkgs.portableService { inherit (web) version; - pname = "infinipaste"; - description = "The infinipaste service"; - homepage = "https://github.com/tailscale-dev/infinipaste"; + pname = "tclip"; + description = "The tclip service"; + homepage = "https://github.com/tailscale-dev/tclip"; units = [ web-service ]; symlinks = [{ object = "${pkgs.cacert}/etc/ssl"; diff --git a/go.mod b/go.mod index cabe63a..ef97c68 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/tailscale-dev/infinipaste +module github.com/tailscale-dev/tclip go 1.19