The blog about containerisation, virtual machines and useful shell snippets and findings

Later Ctrl + ↑

enable gitea to use ssh port 22

  1. Move original ssh service to other port, like 2022
  2. set gitea config to use port 22
    app.ini
[server]
DISABLE_SSH      = false
SSH_PORT         = 22
SSH_LISTEN_HOST  = 0.0.0.0
SSH_LISTEN_PORT  = 22
START_SSH_SERVER = true
  1. execute
sudo setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/gitea to enable usage of the port 22

copy files having search string to the target folder

let’s say you have true in the hundreds of files and you need to copy only those which contain this string, it is quite easy to do with Linux find utility

grep -l -ri -m1 "Active>true" */*.xml | xargs -I {} cp {} target_folder

macos datomic console in background plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>com.cognitect.datomic-console</string>
  <key>ProgramArguments</key>
  <array>
     <string>/Users/nexus/datomic-pro-1.0.6165/bin/console</string>
     <string>stock</string>
     <string>datomic:dev://localhost:4334/stock</string>
     <string>--port</string>
     <string>8080</string>
  </array>
	<key>WorkingDirectory</key>
	<string>/Users/nexus/datomic-pro-1.0.6165</string>
</dict>
</plist>

macos run datomic in background plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>Label</key>
	<string>com.cognitect.datomic</string>
  <key>ProgramArguments</key>
  <array>
     <string>/Users/nexus/datomic-pro-1.0.6165/bin/transactor</string>
     <string>config/dev-transactor.properties</string>
  </array>
	<key>WorkingDirectory</key>
	<string>/Users/nexus/datomic-pro-1.0.6165</string>
</dict>
</plist>

Ansible add entries to .htpassword

There are several ways to do this:

  1. Use template action and use template file
  2. Use array of entries and loop with lininfile command
  3. Use https://docs.ansible.com/ansible/latest/collections/community/general/htpasswd_module.html htpasswd module.

I decided to go with approach #2.
in variables

htpasswd:
  - user1:password1
  - user2:password2

in the playbook

- name: set password file
      lineinfile:
        path: "{{ webroot }}/shared/.htpasswd"
        line: "{{ item }}"
        create: yes
      when: oxid.configuration == "production"
      loop: "{{ htpasswd }}"
Earlier Ctrl + ↓