あなたを待っています...
This commit is contained in:
parent
b1b3523d3d
commit
495ab854ac
3
LICENSE
3
LICENSE
|
|
@ -1,6 +1,7 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2025 LaidBackSYS
|
||||
Copyright (c) 2018-2022 tilde.team
|
||||
Copyright (c) 2025 Yakumo Laboratories
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
install-mkdirs:
|
||||
@install -m 0755 -d ${PREFIX}/share/laidback
|
||||
install: install-mkdirs
|
||||
@install -m 0755 makeuser ${PREFIX}/bin
|
||||
@install -m 0600 mail.tmpl ${PREFIX}/share/laidback
|
||||
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
To: newemail
|
||||
Subject: Welcome ~newuser to hostname
|
||||
|
||||
Welcome newuser-sama,
|
||||
|
||||
You should be able to login at newuser@$hostname, using the SSH key you provided earlier.
|
||||
|
||||
That being said, if you do not want to type the above every time you want to login, you can use this snippet and save it as ~/.ssh/config (in your device)
|
||||
|
||||
Host laidback
|
||||
Hostname hostname
|
||||
User newuser
|
||||
|
||||
Your password is newpassword, change it right away after login with `passwd`
|
||||
It's only useful for E-mail and XMPP, the latter of which can have a different password altogether.
|
||||
|
||||
You can read the (work in progress) documentation here: https://hostname/wiki
|
||||
|
||||
Feel free to contact `support@laidback.moe` if you have any questions.
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
#!/bin/sh
|
||||
|
||||
msg_err() {
|
||||
printf "\033[0;31m%s\033[0m\n" "$*" >&2
|
||||
exit 1
|
||||
}
|
||||
msg_info() {
|
||||
printf "\033[0;32m%s\033[0m\n" "$*"
|
||||
}
|
||||
msg_warn() {
|
||||
printf "\033[0;33m%s\033[0m\n" "$*"
|
||||
}
|
||||
print_usage() {
|
||||
msg_warn "Usage: $(basename $0) [-h|--help] <username> <email> \"<pubkey>\""
|
||||
}
|
||||
|
||||
case $1 in
|
||||
-h | --help)
|
||||
print_usage; exit
|
||||
;;
|
||||
-* | --*)
|
||||
print_usage; exit 1
|
||||
;;
|
||||
*)
|
||||
if [ $# -ne 3 ]; then
|
||||
msg_err "Not enough arguments"
|
||||
fi
|
||||
|
||||
if id "$1" > /dev/null 2>&1; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
hostname="$(hostname)"
|
||||
newpw="$(pwgen -s 20 1)"
|
||||
newpw_hash="$(pwhash $newpw)"
|
||||
|
||||
msg_info "Adding new user: %s" "$1"
|
||||
useradd -m -g users -s "${newpw_hash}" /bin/sh "$1" || msg_err "Unable to create user"
|
||||
|
||||
sed -e "s/newuser/$1/g" \
|
||||
-e "s/newpassword/$newpw/" \
|
||||
-e "s/newemail/$2/" \
|
||||
-e "s/hostname/$hostname/" \
|
||||
/usr/local/share/laidback/email.tmpl | sendmail "$1" "$2"
|
||||
|
||||
|
||||
printf "%s\n" "$3" | doas tee "/home/$1/.ssh/authorized_keys"
|
||||
|
||||
doas -u ejabberd /usr/pkg/sbin/ejabberdctl register "$1" "${hostname}" "$newpw"
|
||||
;;
|
||||
esac
|
||||
Loading…
Reference in New Issue