gigascience / gigadb-website

Source code for running GigaDB
http://gigadb.org
GNU General Public License v3.0
9 stars 14 forks source link

FTP account bulk create script #1860

Open rija opened 4 months ago

rija commented 4 months ago

user story

As a curator I want to create drop boxes for a list of username So that I don't run out of account to distribute

additional infos

on staging and live bastion on Upstream, there is a script that bulk create drop box account and save credentials in a log to be sent to curators. That script needs to be saved in git repo under gigadb/app/tools/drobox-tools/make_dropbox.sh, and then deployed to the FTP servers through the files_playbook.yml.

Tasks

#!/usr/bin/env bash

set -e

touch ./new_dropboxes.txt
date >> ./new_dropboxes.txt
for username in "$@"; do
  echo "Generating password for user $username:"
  password=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13; echo)
  echo $password > /tmp/$username.pass
  echo $password >> /tmp/$username.pass
  echo "$username:$password" >> ./new_dropboxes.txt
  echo "Making directory in /share/dropbox"
  mkdir -p /share/dropbox/$username
  echo "Creating FTP account"
  docker compose exec -T ftpd pure-pw useradd $username -f /etc/pure-ftpd/passwd/pureftpd.passwd -m -u dropboxuser -d /home/$username < /tmp/$username.pass
  echo "Cleaning up"
  rm /tmp/$username.pass
done
rija commented 2 months ago

After PR #1943 is merged, this ticket become simpler to implement as the dropbox creation script can be run from the server the curators have access too (#1876, #1877 and #1878 will become unnecessary)