1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/restic_ynh.git synced 2024-09-03 20:16:22 +02:00

Remove references to SSK key generation

This is probably a step to be done manually, depending on the kind of repository chosen for Restic.
This commit is contained in:
Philippe Bernery 2021-05-11 16:02:35 +02:00
parent f460cf6a48
commit 3c264fed32
3 changed files with 2 additions and 107 deletions

View file

@ -42,15 +42,6 @@
"fr": "Indiquez une phrase de passe forte que vous garderez précieusement si vous voulez être en mesure d'utiliser vos sauvegardes"
}
},
{
"name": "generate_ssh_key",
"type": "boolean",
"ask": {
"en": "Would you like to generate a SSH key? This is useful if you want to save on a SFTP repository.",
"fr": "Souhaitez-vous générer une clé SSH ? C'est utile si vous désirez utiliser SFTP comme méthode de sauvegarde."
},
"default": false
},
{
"name": "conf",
"type": "boolean",

View file

@ -23,12 +23,12 @@ export app=$YNH_APP_INSTANCE_NAME
export final_path="/opt/yunohost/${app}"
# Retrieve arguments
ynh_export repository passphrase generate_ssh_key on_calendar check_on_calendar check_read_data_on_calendar conf data apps allow_extra_space_use
ynh_export repository passphrase on_calendar check_on_calendar check_read_data_on_calendar conf data apps allow_extra_space_use
#=================================================
# STORE SETTINGS FROM MANIFEST
#=================================================
ynh_save_args repository passphrase generate_ssh_key on_calendar check_on_calendar check_read_data_on_calendar conf data apps allow_extra_space_use
ynh_save_args repository passphrase on_calendar check_on_calendar check_read_data_on_calendar conf data apps allow_extra_space_use
#=================================================
# INSTALL RESTIC
@ -114,65 +114,3 @@ ynh_use_logrotate --logfile=/var/log/restic_backup_${app}.log
ynh_use_logrotate --logfile=/var/log/restic_backup_${app}.err
ynh_use_logrotate --logfile=/var/log/restic_check_${app}.log
ynh_use_logrotate --logfile=/var/log/restic_check_${app}.err
if [ "${generate_ssh_key}" = "true" ]; then
#=================================================
# GENERATE SSH KEY
#=================================================
ynh_script_progression --message="Generating private key"
ssh_dir="/root/.ssh"
if [ ! -d "${ssh_dir}" ];then
mkdir -p "${ssh_dir}"
fi
private_key="${ssh_dir}/id_${app}_ed25519"
test -f $private_key || ssh-keygen -q -t ed25519 -N "" -f $private_key
#=================================================
# GENERATE SSH CONFIG
#=================================================
ynh_script_progression --message="Generating ssh config for ${app} server ${server}"
grep -q "${app}" ${ssh_dir}/config 2>/dev/null || cat << EOCONF >> ${ssh_dir}/config
# begin $app ssh config
Host ${server}
Hostname ${server}
Port ${port}
User ${ssh_user}
IdentityFile ${private_key}
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
# end $app ssh config
EOCONF
#=================================================
# Display key
#=================================================
ynh_script_progression --message="You should now allow the following public key for user ${ssh_user} on server ${server}:
$(cat ${private_key}.pub)"
#=================================================
# SEND A README FOR THE ADMIN
#=================================================
ynh_script_progression --message="Sending post-installation instructions to admin" --last
ynh_print_OFF
message="You should now allow the following public key for user ${ssh_user} on server ${server}:
$(cat ${private_key}.pub)
Do so by running those commands on ${server} with user ${ssh_user}:
mkdir ~/.ssh 2>/dev/null
touch ~/.ssh/authorized_keys
chmod u=rw,go= ~/.ssh/authorized_keys
cat << EOPKEY >> ~/.ssh/authorized_keys
$(cat ${private_key}.pub)
EOPKEY
$(if [ "$backup_path" != "./" ];then echo "Also make sure ${backup_path} exists and is writable by ${ssh_user}";fi)
If you're facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/restic_ynh"
ynh_send_readme_to_admin "$message" "root"
ynh_print_ON
fi

View file

@ -17,7 +17,6 @@ export app=$YNH_APP_INSTANCE_NAME
export final_path="/opt/yunohost/${app}"
export repository=$(ynh_app_setting_get $app repository)
export passphrase=$(ynh_app_setting_get $app passphrase)
export generate_ssh_key=$(ynh_app_setting_get $app generate_ssh_key)
export on_calendar=$(ynh_app_setting_get $app on_calendar)
export check_on_calendar=$(ynh_app_setting_get $app check_on_calendar)
export check_read_data_on_calendar=$(ynh_app_setting_get $app check_read_data_on_calendar)
@ -155,36 +154,3 @@ ynh_use_logrotate --logfile=/var/log/restic_backup_${app}.log
ynh_use_logrotate --logfile=/var/log/restic_backup_${app}.err
ynh_use_logrotate --logfile=/var/log/restic_check_${app}.log
ynh_use_logrotate --logfile=/var/log/restic_check_${app}.err
if [ "${generate_ssh_key}" = "true" ]; then
#=================================================
# UPGRADE SSH CONFIG
#=================================================
# old versions did not have delimiters in ~/.ssh/config
# making removal in multi-instance cases break the remaining
# instances.
# So we need to add the delimiters if they are missing
set +o errexit
set +o nounset
grep -q "begin ${app}" ${ssh_dir}/config
missing_delimiters="$?"
if [ "$missing_delimiters" -eq 1 ];then
# did not find delimiters so removing old configuration
sed -e "/Host ${server}/,+6d" ${ssh_dir}/config -i || true
cat << EOCONF >> ${ssh_dir}/config
# begin $app ssh config
Host ${server}
Hostname ${server}
Port ${port}
User ${ssh_user}
IdentityFile ${private_key}
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
# end $app ssh config
EOCONF
fi
ynh_script_progression --message="End of upgrade process" --last
fi