mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Merge pull request #454 from schnuffle/pre-commit
Corrections to pass pre-commit hooks
This commit is contained in:
		
							
								
								
									
										10
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								Dockerfile
									
									
									
									
									
								
							| @@ -11,7 +11,15 @@ FROM ubuntu:20.04 AS jbig2enc | |||||||
|  |  | ||||||
| WORKDIR /usr/src/jbig2enc | WORKDIR /usr/src/jbig2enc | ||||||
|  |  | ||||||
| RUN apt-get update && apt-get install -y --no-install-recommends build-essential automake libtool libleptonica-dev zlib1g-dev git ca-certificates | RUN apt-get update \ | ||||||
|  |   && apt-get install -y --no-install-recommends build-essential \ | ||||||
|  |     automake \ | ||||||
|  |     libtool \ | ||||||
|  |     libleptonica-dev \ | ||||||
|  |     zlib1g-dev \ | ||||||
|  |     git \ | ||||||
|  |     ca-certificates \ | ||||||
|  |   && rm -rf /var/lib/apt/lists/* | ||||||
|  |  | ||||||
| RUN git clone https://github.com/agl/jbig2enc . | RUN git clone https://github.com/agl/jbig2enc . | ||||||
| RUN ./autogen.sh | RUN ./autogen.sh | ||||||
|   | |||||||
| @@ -56,12 +56,12 @@ install_languages() { | |||||||
| 		#    continue | 		#    continue | ||||||
| 		#fi | 		#fi | ||||||
|  |  | ||||||
| 		if dpkg -s $pkg &>/dev/null; then | 		if dpkg -s "$pkg" &>/dev/null; then | ||||||
| 			echo "Package $pkg already installed!" | 			echo "Package $pkg already installed!" | ||||||
| 			continue | 			continue | ||||||
| 		fi | 		fi | ||||||
|  |  | ||||||
| 		if ! apt-cache show $pkg &>/dev/null; then | 		if ! apt-cache show "$pkg" &>/dev/null; then | ||||||
| 			echo "Package $pkg not found! :(" | 			echo "Package $pkg not found! :(" | ||||||
| 			continue | 			continue | ||||||
| 		fi | 		fi | ||||||
| @@ -77,7 +77,7 @@ install_languages() { | |||||||
| echo "Paperless-ngx docker container starting..." | echo "Paperless-ngx docker container starting..." | ||||||
|  |  | ||||||
| # Install additional languages if specified | # Install additional languages if specified | ||||||
| if [[ ! -z "$PAPERLESS_OCR_LANGUAGES" ]]; then | if [[ -n "$PAPERLESS_OCR_LANGUAGES" ]]; then | ||||||
| 	install_languages "$PAPERLESS_OCR_LANGUAGES" | 	install_languages "$PAPERLESS_OCR_LANGUAGES" | ||||||
| fi | fi | ||||||
|  |  | ||||||
|   | |||||||
| @@ -6,14 +6,11 @@ wait_for_postgres() { | |||||||
|  |  | ||||||
| 	echo "Waiting for PostgreSQL to start..." | 	echo "Waiting for PostgreSQL to start..." | ||||||
|  |  | ||||||
| 	host="${PAPERLESS_DBHOST}" | 	host="${PAPERLESS_DBHOST:=localhost}" | ||||||
| 	port="${PAPERLESS_DBPORT}" | 	port="${PAPERLESS_DBPORT:=5342}" | ||||||
|  |  | ||||||
| 	if [[ -z $port ]]; then |  | ||||||
| 		port="5432" |  | ||||||
| 	fi |  | ||||||
|  |  | ||||||
| 	while ! </dev/tcp/$host/$port; do | 	while [ ! "$(pg_isready -h $host -p $port)" ]; do | ||||||
|  |  | ||||||
| 		if [ $attempt_num -eq $max_attempts ]; then | 		if [ $attempt_num -eq $max_attempts ]; then | ||||||
| 			echo "Unable to connect to database." | 			echo "Unable to connect to database." | ||||||
| @@ -23,7 +20,7 @@ wait_for_postgres() { | |||||||
|  |  | ||||||
| 		fi | 		fi | ||||||
|  |  | ||||||
| 		attempt_num=$(expr "$attempt_num" + 1) | 		attempt_num=$(("$attempt_num" + 1)) | ||||||
| 		sleep 5 | 		sleep 5 | ||||||
| 	done | 	done | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,3 +1,5 @@ | |||||||
|  | #!/usr/bin/env bash | ||||||
|  |  | ||||||
| for command in document_archiver document_exporter document_importer mail_fetcher document_create_classifier document_index document_renamer document_retagger document_thumbnails document_sanity_checker manage_superuser; | for command in document_archiver document_exporter document_importer mail_fetcher document_create_classifier document_index document_renamer document_retagger document_thumbnails document_sanity_checker manage_superuser; | ||||||
| do | do | ||||||
| 	echo "installing $command..." | 	echo "installing $command..." | ||||||
|   | |||||||
| @@ -6,10 +6,10 @@ cd /usr/src/paperless/src/ | |||||||
|  |  | ||||||
| if [[ $(id -u) == 0 ]] ; | if [[ $(id -u) == 0 ]] ; | ||||||
| then | then | ||||||
|   gosu paperless python3 manage.py management_command "$@" | 	gosu paperless python3 manage.py management_command "$@" | ||||||
| elif [[ $(id -un) == "paperless" ]] ; | elif [[ $(id -un) == "paperless" ]] ; | ||||||
| then | then | ||||||
|   python3 manage.py management_command "$@" | 	python3 manage.py management_command "$@" | ||||||
| else | else | ||||||
|   echo "Unknown user." | 	echo "Unknown user." | ||||||
| fi | fi | ||||||
|   | |||||||
| @@ -1,5 +1,4 @@ | |||||||
| FROM python:3.5.1 | FROM python:3.5.1 | ||||||
| MAINTAINER Pit Kleyersburg <pitkley@googlemail.com> |  | ||||||
|  |  | ||||||
| # Install Sphinx and Pygments | # Install Sphinx and Pygments | ||||||
| RUN pip install Sphinx Pygments | RUN pip install Sphinx Pygments | ||||||
|   | |||||||
| @@ -42,4 +42,3 @@ Mobile support in the future? This kinda works, however some layouts are still | |||||||
| too wide. | too wide. | ||||||
|  |  | ||||||
| .. image:: _static/screenshots/mobile.png | .. image:: _static/screenshots/mobile.png | ||||||
|  |  | ||||||
|   | |||||||
| @@ -3,16 +3,16 @@ | |||||||
| ask() { | ask() { | ||||||
| 	while true ; do | 	while true ; do | ||||||
| 		if [[ -z $3 ]] ; then | 		if [[ -z $3 ]] ; then | ||||||
| 			read -p "$1 [$2]: " result | 			read -r -p "$1 [$2]: " result | ||||||
| 		else | 		else | ||||||
| 			read -p "$1 ($3) [$2]: " result | 			read -r -p "$1 ($3) [$2]: " result | ||||||
| 		fi | 		fi | ||||||
| 		if [[ -z $result ]]; then | 		if [[ -z $result ]]; then | ||||||
| 			ask_result=$2 | 			ask_result=$2 | ||||||
| 			return | 			return | ||||||
| 		fi | 		fi | ||||||
| 		array=$3 | 		array=$3 | ||||||
| 		if [[ -z $3 || " ${array[@]} " =~ " ${result} " ]]; then | 		if [[ -z $3 || " ${array[*]} " =~ ${result} ]]; then | ||||||
| 			ask_result=$result | 			ask_result=$result | ||||||
| 			return | 			return | ||||||
| 		else | 		else | ||||||
| @@ -24,7 +24,7 @@ ask() { | |||||||
| ask_docker_folder() { | ask_docker_folder() { | ||||||
| 	while true ; do | 	while true ; do | ||||||
|  |  | ||||||
| 		read -p "$1 [$2]: " result | 		read -r -p "$1 [$2]: " result | ||||||
|  |  | ||||||
| 		if [[ -z $result ]]; then | 		if [[ -z $result ]]; then | ||||||
| 			ask_result=$2 | 			ask_result=$2 | ||||||
| @@ -64,8 +64,7 @@ fi | |||||||
|  |  | ||||||
| # Check if user has permissions to run Docker by trying to get the status of Docker (docker status). | # Check if user has permissions to run Docker by trying to get the status of Docker (docker status). | ||||||
| # If this fails, the user probably does not have permissions for Docker. | # If this fails, the user probably does not have permissions for Docker. | ||||||
| docker stats --no-stream 2>/dev/null 1>&2 | if [ ! "$(docker stats --no-stream 2>/dev/null 1>&2)" ] ; then | ||||||
| if [ $? -ne 0 ] ; then |  | ||||||
| 	echo "" | 	echo "" | ||||||
| 	echo "WARN: It look like the current user does not have Docker permissions." | 	echo "WARN: It look like the current user does not have Docker permissions." | ||||||
| 	echo "WARN: Use 'sudo usermod -aG docker $USER' to assign Docker permissions to the user." | 	echo "WARN: Use 'sudo usermod -aG docker $USER' to assign Docker permissions to the user." | ||||||
| @@ -228,7 +227,7 @@ ask "Paperless username" "$(whoami)" | |||||||
| USERNAME=$ask_result | USERNAME=$ask_result | ||||||
|  |  | ||||||
| while true; do | while true; do | ||||||
| 	read -sp "Paperless password: " PASSWORD | 	read -r -sp "Paperless password: " PASSWORD | ||||||
| 	echo "" | 	echo "" | ||||||
|  |  | ||||||
| 	if [[ -z $PASSWORD ]] ; then | 	if [[ -z $PASSWORD ]] ; then | ||||||
| @@ -236,7 +235,7 @@ while true; do | |||||||
| 		continue | 		continue | ||||||
| 	fi | 	fi | ||||||
|  |  | ||||||
| 	read -sp "Paperless password (again): " PASSWORD_REPEAT | 	read -r -sp "Paperless password (again): " PASSWORD_REPEAT | ||||||
| 	echo "" | 	echo "" | ||||||
|  |  | ||||||
| 	if [[ ! "$PASSWORD" == "$PASSWORD_REPEAT" ]] ; then | 	if [[ ! "$PASSWORD" == "$PASSWORD_REPEAT" ]] ; then | ||||||
| @@ -285,7 +284,7 @@ echo "Paperless username: $USERNAME" | |||||||
| echo "Paperless email: $EMAIL" | echo "Paperless email: $EMAIL" | ||||||
|  |  | ||||||
| echo "" | echo "" | ||||||
| read -p "Press any key to install." | read -r -p "Press any key to install." | ||||||
|  |  | ||||||
| echo "" | echo "" | ||||||
| echo "Installing paperless..." | echo "Installing paperless..." | ||||||
| @@ -304,7 +303,7 @@ fi | |||||||
| wget "https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/docker/compose/docker-compose.$DOCKER_COMPOSE_VERSION.yml" -O docker-compose.yml | wget "https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/docker/compose/docker-compose.$DOCKER_COMPOSE_VERSION.yml" -O docker-compose.yml | ||||||
| wget "https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/docker/compose/.env" -O .env | wget "https://raw.githubusercontent.com/paperless-ngx/paperless-ngx/main/docker/compose/.env" -O .env | ||||||
|  |  | ||||||
| SECRET_KEY=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1) | SECRET_KEY=$(tr -dc 'a-zA-Z0-9' < /dev/urandom | fold -w 64 | head -n 1) | ||||||
|  |  | ||||||
| DEFAULT_LANGUAGES="deu eng fra ita spa" | DEFAULT_LANGUAGES="deu eng fra ita spa" | ||||||
|  |  | ||||||
| @@ -318,7 +317,7 @@ DEFAULT_LANGUAGES="deu eng fra ita spa" | |||||||
| 	echo "PAPERLESS_TIME_ZONE=$TIME_ZONE" | 	echo "PAPERLESS_TIME_ZONE=$TIME_ZONE" | ||||||
| 	echo "PAPERLESS_OCR_LANGUAGE=$OCR_LANGUAGE" | 	echo "PAPERLESS_OCR_LANGUAGE=$OCR_LANGUAGE" | ||||||
| 	echo "PAPERLESS_SECRET_KEY=$SECRET_KEY" | 	echo "PAPERLESS_SECRET_KEY=$SECRET_KEY" | ||||||
| 	if [[ ! " ${DEFAULT_LANGUAGES[@]} " =~ " ${OCR_LANGUAGE} " ]] ; then | 	if [[ ! " ${DEFAULT_LANGUAGES[*]} " =~ ${OCR_LANGUAGE} ]] ; then | ||||||
| 		echo "PAPERLESS_OCR_LANGUAGES=$OCR_LANGUAGE" | 		echo "PAPERLESS_OCR_LANGUAGES=$OCR_LANGUAGE" | ||||||
| 	fi | 	fi | ||||||
| } > docker-compose.env | } > docker-compose.env | ||||||
| @@ -334,12 +333,12 @@ fi | |||||||
|  |  | ||||||
| if [[ -n $DATA_FOLDER ]] ; then | if [[ -n $DATA_FOLDER ]] ; then | ||||||
| 	sed -i "s#- data:/usr/src/paperless/data#- $DATA_FOLDER:/usr/src/paperless/data#g" docker-compose.yml | 	sed -i "s#- data:/usr/src/paperless/data#- $DATA_FOLDER:/usr/src/paperless/data#g" docker-compose.yml | ||||||
|     sed -i "/^\s*data:/d" docker-compose.yml | 	sed -i "/^\s*data:/d" docker-compose.yml | ||||||
| fi | fi | ||||||
|  |  | ||||||
| if [[ -n $POSTGRES_FOLDER ]] ; then | if [[ -n $POSTGRES_FOLDER ]] ; then | ||||||
| 	sed -i "s#- pgdata:/var/lib/postgresql/data#- $POSTGRES_FOLDER:/var/lib/postgresql/data#g" docker-compose.yml | 	sed -i "s#- pgdata:/var/lib/postgresql/data#- $POSTGRES_FOLDER:/var/lib/postgresql/data#g" docker-compose.yml | ||||||
|     sed -i "/^\s*pgdata:/d" docker-compose.yml | 	sed -i "/^\s*pgdata:/d" docker-compose.yml | ||||||
| fi | fi | ||||||
|  |  | ||||||
| # remove trailing blank lines from end of file | # remove trailing blank lines from end of file | ||||||
| @@ -348,7 +347,7 @@ sed -i -e :a -e '/^\n*$/{$d;N;};/\n$/ba' docker-compose.yml | |||||||
| l1=$(grep -n '^volumes:' docker-compose.yml | cut -d : -f 1)  # get line number containing volume: at begin of line | l1=$(grep -n '^volumes:' docker-compose.yml | cut -d : -f 1)  # get line number containing volume: at begin of line | ||||||
| l2=$(wc -l < docker-compose.yml)  # get total number of lines | l2=$(wc -l < docker-compose.yml)  # get total number of lines | ||||||
| if [ "$l1" -eq "$l2" ] ; then | if [ "$l1" -eq "$l2" ] ; then | ||||||
|     sed -i "/^volumes:/d" docker-compose.yml | 	sed -i "/^volumes:/d" docker-compose.yml | ||||||
| fi | fi | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,3 +1,5 @@ | |||||||
|  | #!/usr/bin/env bash | ||||||
|  |  | ||||||
| docker run -p 5432:5432 -e POSTGRES_PASSWORD=password -v paperless_pgdata:/var/lib/postgresql/data -d postgres:13 | docker run -p 5432:5432 -e POSTGRES_PASSWORD=password -v paperless_pgdata:/var/lib/postgresql/data -d postgres:13 | ||||||
| docker run -d -p 6379:6379 redis:latest | docker run -d -p 6379:6379 redis:latest | ||||||
| docker run -p 3000:3000 -d gotenberg/gotenberg:7 | docker run -p 3000:3000 -d gotenberg/gotenberg:7 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 shamoon
					shamoon