import db
This commit is contained in:
32
app/sbin/ODOO_19/import
Normal file
32
app/sbin/ODOO_19/import
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Create the tmp directory if it doesn't exist
|
||||
mkdir -p /4server/tmp/
|
||||
|
||||
# Save original stdout
|
||||
exec 3>&1
|
||||
|
||||
# Redirect all other output to log
|
||||
exec > /4server/data/log/importDb.log 2>&1
|
||||
echo "$(date '+%Y-%m-%d %H:%M') Import file $1"
|
||||
|
||||
# Generate random 8-digit filename
|
||||
RANDOM_FILE="/4server/tmp/$(printf "%08d" $((RANDOM % 100000000))).zip"
|
||||
|
||||
# Download file from Google Drive using gdown
|
||||
gdown "$1" -O "$RANDOM_FILE"
|
||||
|
||||
# Execute dbVersion on the downloaded file and capture output
|
||||
VERSION=$(/4server/sbin/ODOO_19/dbVersion "$RANDOM_FILE")
|
||||
|
||||
# Output JSON to original stdout
|
||||
cat <<EOF >&3
|
||||
{
|
||||
"version":"$VERSION",
|
||||
"file":"$RANDOM_FILE"
|
||||
}
|
||||
EOF
|
||||
|
||||
# Close saved stdout
|
||||
exec 3>&-
|
||||
|
||||
Reference in New Issue
Block a user