aptosaurus/cron.sh

25 lines
802 B
Bash
Raw Normal View History

2019-08-09 23:00:14 +00:00
#!/usr/bin/env bash
2020-11-27 01:33:42 +00:00
set -e;
source="/home/ci/sftp-root/apt-packages";
2019-08-09 23:00:14 +00:00
destination="/srv/aptosaurus/sources";
aptosaurus="/srv/aptosaurus/aptosaurus.sh";
HOME="$(dirname "${aptosaurus}")";
export HOME;
2019-08-09 23:00:14 +00:00
# The user account to chown to & run aptosaurus under
# FUTURE: Use own account? Is it worth it for a cron job?
user_account="daemon";
2019-09-06 17:09:39 +00:00
# Locate & move the .deb files into place
2023-06-26 21:04:59 +00:00
find "${source}" -type f -name "*.deb" -print0 | xargs -I{} --null mv "{}" "${destination}";
2019-08-09 23:00:14 +00:00
# chown them to the right user account
chown -R "${user_account}:${user_account}" "${destination}";
# Re-run aptosaurus
aptosaurus_dir="$(dirname "${aptosaurus}")";
cd "${aptosaurus_dir}" || { echo "Failed to cd into aptosaurus directory"; exit 1; };
sudo -u "${user_account}" bash "$(basename "${aptosaurus}")" update-cron;