Remove old files + add sane config

This commit is contained in:
Alexandre CATTEAU 2021-10-31 13:36:44 +01:00
parent e321ce0809
commit c6eeb14cfc
11 changed files with 7 additions and 134 deletions

View File

@ -1,7 +0,0 @@
[Unit]
Description=Clean remote dropbox
[Service]
User=scan
Type=oneshot
ExecStart=/home/scan/.sync/clean-cloud.sh

View File

@ -1,25 +0,0 @@
#!/bin/bash
# The purpose of this script is to automatically empty our remote sandbox.
# This script is not to be run as root, rather as the user responsible for scanning.
# Only run if the user is not root
if [[ $USER = 'root' ]] ; then
echo "You must not run this script as root!"
exit 1
fi
# Set parameters
remote_path='https://cloud.kto.black/remote.php/webdav/Scans'
remote_user='scan'
remote_passwd='rB2TgFpNXk3BbZ44'
subdirectories_prefix='scans'
yesterday=$(date -d "-1 days" +"%Y%m%d")
today=$(date +"%Y%m%d")
curl -s -u $remote_user:$remote_passwd -X DELETE $remote_path/$subdirectories_prefix-$yesterday
curl -s -u $remote_user:$remote_passwd -X MKCOL $remote_path/$subdirectories_prefix-$today
echo "Cleaning done."
exit 0

View File

@ -1,9 +0,0 @@
[Unit]
Description=Run clean-cloud regularly
[Timer]
OnCalendar=*-*-* 02:00:00
Persistent=true
[Install]
WantedBy=timers.target

View File

@ -1,10 +0,0 @@
[Unit]
Description=noVNC proxy with Websockify
[Service]
User=scan
Type=simple
ExecStart=/usr/bin/websockify --ssl-only --cert /etc/ssl/cert.crt --key /etc/ssl/cert.key --web /usr/share/novnc 8080 localhost:5900
[Install]
WantedBy=default.target

View File

@ -1,8 +0,0 @@
[Unit]
Description=Run scan-to-cloud when a new document is scanned
[Path]
DirectoryNotEmpty=/scan
[Install]
WantedBy=paths.target

View File

@ -1,7 +0,0 @@
[Unit]
Description=Upload scanned document to dropbox
[Service]
User=scan
Type=oneshot
ExecStart=/home/scan/.sync/scan-to-cloud.sh

View File

@ -1,33 +0,0 @@
#!/bin/bash
# The purpose of this script is to automaticaly upload scanned documents to a remote dropbox.
# This script is not to be run as root, rather as the user responsible for scanning.
# Only run if the user is not root
if [[ $USER = 'root' ]] ; then
echo "You must not run this script as root!"
exit 1
fi
# Set parameters
scan_directory='/scan'
remote_path='https://cloud.kto.black/remote.php/webdav/Scans'
remote_user='scan'
remote_passwd='rB2TgFpNXk3BbZ44'
subdirectories_prefix='scans'
today=$(date +"%Y%m%d")
# The script is executed a bit too early, so we need to wait a few seconds.
sleep 5s
for filename in $scan_directory/*; do
#echo "Creating today's directory..." # I'd like to remove these 2 lines
#curl -s -u $remote_user:$remote_passwd -X MKCOL $remote_path/$subdirectories_prefix-$today
echo "Uploading $filename..."
curl -s -u $remote_user:$remote_passwd -T "$filename" $remote_path/$subdirectories_prefix-$today/
rm "$filename"
done
echo "Upload done."
exit 0

View File

@ -1,11 +0,0 @@
[Unit]
Description=tmpfs for scanned documents
[Mount]
What=tmpfs
Where=/scan
Type=tmpfs
Options=noatime,uid=1001,gid=1001
[Install]
WantedBy=default.target

View File

@ -56,6 +56,11 @@ set_cups_conf() {
ln -s $sync_directory_path/cupsd.conf $cups_conf_path/cupsd.conf
}
set_sane_conf() {
echo $printscan_container_ip >> /etc/sane.d/saned.conf
systemctl enable saned.socket
}
rcs_links() {
echo "Linking rcs"
rm /home/$user/.bashrc
@ -97,6 +102,7 @@ scan_user_home_directory="/home/$scan_user"
sync_directory_path="/home/$user/.sync"
systemd_units_path='/etc/systemd/system'
cups_conf_path='/etc/cups'
printscan_container_ip='192.168.0.91'
remote_pubkey_location='https://keys.kto.black'
remote_pubkey='home.pub'
@ -108,6 +114,7 @@ add_users
get_conf
set_conf
set_cups_conf
set_sane_conf
rcs_links
ssh_pubkey

View File

@ -1,10 +0,0 @@
[Unit]
Description=VNC incoming socket
[Socket]
ListenStream=127.0.0.1:5900
Accept=yes
MaxConnections=5
[Install]
WantedBy=sockets.target

View File

@ -1,14 +0,0 @@
# VNC password should be set in /etc/passwdd
# TODO we still need to handle session termination
[Unit]
Description=Specific x11vnc session
OnFailure=scan-to-cloud.service
[Service]
User=scan
Type=simple
ExecStart=/usr/bin/x11vnc -once -create -localhost -inetd -bg -o /var/log/x11vnc.log -rfbauth /etc/passwdd
#ExecStop=/usr/bin/x11vnc -R stop # TODO test that, unless it prevents OnFailure from working
StandardInput=socket
StandardError=syslog