initial
This commit is contained in:
commit
3400f9f90f
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/.idea
|
47
release-book.sh
Executable file
47
release-book.sh
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
FILES_DIR="$HOME/files"
|
||||||
|
ARCHIVE_DIR="$FILES_DIR/4in1-old-versions"
|
||||||
|
|
||||||
|
fatal() {
|
||||||
|
>&2 echo "error: $@"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
get_modification_time() {
|
||||||
|
file_path="$1"
|
||||||
|
|
||||||
|
if [ ! -e "$file_path" ]; then
|
||||||
|
fatal "file not found: $file_path"
|
||||||
|
fi
|
||||||
|
|
||||||
|
mod_time=$(stat -c "%Y" "$file_path")
|
||||||
|
formatted_mod_time=$(date -d "@$mod_time" "+%Y-%m-%d")
|
||||||
|
echo "$formatted_mod_time"
|
||||||
|
}
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
>&2 echo "usage: $0 <filename> en|ru"
|
||||||
|
}
|
||||||
|
|
||||||
|
[ $# -ne 2 ] && { usage; exit 1; }
|
||||||
|
|
||||||
|
INPUT="$1"
|
||||||
|
LANG="$2"
|
||||||
|
|
||||||
|
case $LANG in
|
||||||
|
en|ru) : ;;
|
||||||
|
*) fatal "invalid language" ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
target_file="$FILES_DIR/4in1-$LANG.pdf"
|
||||||
|
old_date="$(get_modification_time "$INPUT")"
|
||||||
|
|
||||||
|
[ -d "$ARCHIVE_DIR" ] || {
|
||||||
|
mkdir "$ARCHIVE_DIR"
|
||||||
|
chmod 755 "$ARCHIVE_DIR"
|
||||||
|
chgrp www-data "$ARCHIVE_DIR"
|
||||||
|
}
|
||||||
|
|
||||||
|
mv "$target_file" "$ARCHIVE_DIR/4in1-$LANG-$old_date.pdf"
|
||||||
|
mv "$INPUT" "$target_file"
|
Loading…
x
Reference in New Issue
Block a user