mirror of
				https://github.com/simon987/sist2.git
				synced 2025-10-30 23:46:52 +00:00 
			
		
		
		
	Merge pull request #251 from yatli/example_systemd
add systemd integration example
This commit is contained in:
		
						commit
						b483447b1c
					
				
							
								
								
									
										7
									
								
								contrib/systemd/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								contrib/systemd/Makefile
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,7 @@ | ||||
| install: | ||||
| 	install sist2-update-all.sh /usr/bin/sist2-update-all.sh | ||||
| 	install sist2-update-files.sh /usr/bin/sist2-update-files.sh | ||||
| 	install sist2-update-nextcloud.sh /usr/bin/sist2-update-nextcloud.sh | ||||
| 	install sist2-update.service /etc/systemd/system/sist2-update.service | ||||
| 	install sist2-update.timer /etc/systemd/system/sist2-update.timer | ||||
| 	systemctl daemon-reload | ||||
							
								
								
									
										31
									
								
								contrib/systemd/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										31
									
								
								contrib/systemd/README.md
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,31 @@ | ||||
| # Systemd integration example | ||||
| 
 | ||||
| This example contains my (yatli) personal configuration for sist2 auto-updating. | ||||
| The following indices are involved in this configuration: | ||||
| 
 | ||||
| | Index     | Path             | Description                                | | ||||
| |-----------|------------------|--------------------------------------------| | ||||
| | files     | /zpool/files     | Main file repository                       | | ||||
| | nextcloud | /zpool/nextcloud | Externally synchronized to a cloud account | | ||||
| 
 | ||||
| The systemd integration achieves automatic sist2 scanning & indexing everyday at 3:00AM. | ||||
| 
 | ||||
| ### Tailoring the configuration for yourself | ||||
| 
 | ||||
| `sist2-update-all.sh` calls update scripts for each sist2 index. Add or remove | ||||
| update scripts accordingly to suit your need. Each update script (e.g. | ||||
| `sist2-update-files.sh`) has important parameters laid down at the beginning so | ||||
| make sure to edit them to point to your files and index locations. | ||||
| 
 | ||||
| ### Installation | ||||
| 
 | ||||
| ```bash | ||||
| # install the services and scripts | ||||
| sudo make install | ||||
| # enable & start the timer | ||||
| sudo systemctl enable sist2-update.timer | ||||
| sudo systemctl start sist2-update.timer | ||||
| # verify that the timer has been enabled | ||||
| systemctl list-timers --all | ||||
| ``` | ||||
| 
 | ||||
							
								
								
									
										9
									
								
								contrib/systemd/sist2-update-all.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								contrib/systemd/sist2-update-all.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,9 @@ | ||||
| #!/bin/bash | ||||
| set -e | ||||
| __dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | ||||
| echo "Update index: Files" | ||||
| source ${__dir}/sist2-update-files.sh | ||||
| echo "Update index: Nextcloud" | ||||
| source ${__dir}/sist2-update-nextcloud.sh | ||||
| echo "Done. Restarting sist2." | ||||
| docker restart sist2-sist2-1 | ||||
							
								
								
									
										34
									
								
								contrib/systemd/sist2-update-files.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										34
									
								
								contrib/systemd/sist2-update-files.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,34 @@ | ||||
| #!/bin/bash | ||||
| set -e | ||||
| DATE=$(date +%Y_%m_%d) | ||||
| CONTENT=/zpool/files | ||||
| ORIG=/mnt/ssd/sist-index/files.idx | ||||
| NEW=/mnt/ssd/sist-index/files_$DATE.idx | ||||
| EXCLUDE='ZArchives|TorrentStore|TorrentDownload|624f0c59-1fef-44f6-95e9-7483296f2833|ubuntu-full-2021-12-07' | ||||
| NAME=Files | ||||
| #REWRITE_URL="http://localhost:33333/activate?collection=$NAME&path=" | ||||
| REWRITE_URL="" | ||||
| 
 | ||||
| sist2 scan \ | ||||
|   --threads 14 \ | ||||
|   --mem-throttle 32768 \ | ||||
|   --quality 1.0 \ | ||||
|   --name $NAME \ | ||||
|   --ocr-lang=eng+chi_sim \ | ||||
|   --ocr-ebooks \ | ||||
|   --ocr-images \ | ||||
|   --exclude=$EXCLUDE \ | ||||
|   --rewrite-url=$REWRITE_URL \ | ||||
|   --incremental=$ORIG \ | ||||
|   --output=$NEW \ | ||||
|   $CONTENT | ||||
| echo ">>> Scan complete" | ||||
| rm -rf $ORIG | ||||
| mv $NEW $ORIG  | ||||
| 
 | ||||
| unset http_proxy | ||||
| unset https_proxy | ||||
| unset HTTP_PROXY | ||||
| unset HTTPS_PROXY | ||||
| sist2 index $ORIG --incremental-index | ||||
| echo ">>> Index complete" | ||||
							
								
								
									
										33
									
								
								contrib/systemd/sist2-update-nextcloud.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										33
									
								
								contrib/systemd/sist2-update-nextcloud.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,33 @@ | ||||
| #!/bin/bash | ||||
| set -e | ||||
| DATE=$(date +%Y_%m_%d) | ||||
| CONTENT=/zpool/nextcloud/v-yadli | ||||
| ORIG=/mnt/ssd/sist-index/nextcloud.idx | ||||
| NEW=/mnt/ssd/sist-index/nextcloud_$DATE.idx | ||||
| EXCLUDE='Yatao|.*263418493\\/Image\\/.*' | ||||
| NAME=NextCloud | ||||
| # REWRITE_URL="http://localhost:33333/activate?collection=$NAME&path=" | ||||
| REWRITE_URL="" | ||||
| 
 | ||||
| sist2 scan \ | ||||
|   --threads 14 \ | ||||
|   --mem-throttle 32768 \ | ||||
|   --quality 1.0 \ | ||||
|   --name $NAME \ | ||||
|   --ocr-lang=eng+chi_sim \ | ||||
|   --ocr-ebooks \ | ||||
|   --ocr-images \ | ||||
|   --exclude=$EXCLUDE \ | ||||
|   --rewrite-url=$REWRITE_URL \ | ||||
|   --incremental=$ORIG \ | ||||
|   --output=$NEW \ | ||||
|   $CONTENT | ||||
| echo ">>> Scan complete" | ||||
| rm -rf $ORIG | ||||
| mv $NEW $ORIG  | ||||
| 
 | ||||
| unset http_proxy | ||||
| unset https_proxy | ||||
| unset HTTP_PROXY | ||||
| unset HTTPS_PROXY | ||||
| sist2 index $ORIG --incremental-index | ||||
							
								
								
									
										6
									
								
								contrib/systemd/sist2-update.service
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								contrib/systemd/sist2-update.service
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,6 @@ | ||||
| [Unit] | ||||
| Description=sist2-update | ||||
| 
 | ||||
| [Service] | ||||
| User=yatli | ||||
| ExecStart=/bin/bash /usr/bin/sist2-update-all.sh | ||||
							
								
								
									
										10
									
								
								contrib/systemd/sist2-update.timer
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								contrib/systemd/sist2-update.timer
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,10 @@ | ||||
| [Unit] | ||||
| Description=sist2-update | ||||
| 
 | ||||
| [Timer] | ||||
| OnCalendar=*-*-* 3:00:00 | ||||
| Persistent=true | ||||
| Unit=sist2-update.service | ||||
| 
 | ||||
| [Install] | ||||
| WantedBy=timers.target | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user