fix(nas): environment loaded in wrong order / use safari again because of a cookie library bug

This commit is contained in:
Jan-Ole Hübner 2025-04-14 11:38:22 +02:00
parent 5521f3de6c
commit 74c37f0a2a
2 changed files with 61 additions and 61 deletions

View file

@ -1,75 +1,75 @@
insta () { insta () {
local cwd=$(pwd) local cwd=$(pwd)
check_smb_mount () { check_smb_mount () {
/sbin/mount | grep -q "$insta_mount_point" /sbin/mount | grep -q "$insta_mount_point"
} }
local stories_only=false local stories_only=false
local user_list=() local user_list=()
while [[ $# -gt 0 ]] while [[ $# -gt 0 ]]
do do
case "$1" in case "$1" in
--cron) --cron)
local random_wait=$((RANDOM % 1800)) local random_wait=$((RANDOM % 1800))
echo "--------------------------------------------" echo "--------------------------------------------"
echo "Waiting for $((random_wait / 60)) minutes..." echo "Waiting for $((random_wait / 60)) minutes..."
sleep $random_wait sleep $random_wait
stories_only=true stories_only=true
;; ;;
--stories) --stories)
stories_only=true stories_only=true
;; ;;
*) *)
user_list+=("$1") user_list+=("$1")
;; ;;
esac esac
shift shift
done done
echo "-----$(date)------" echo "-----$(date)------"
local is_local_nas=false local is_local_nas=false
if [[ "$NAS_IP" == "127.0.0.1" || "$NAS_IP" == "localhost" ]]; then if [[ "$NAS_IP" == "127.0.0.1" || "$NAS_IP" == "localhost" ]]; then
is_local_nas=true is_local_nas=true
fi fi
if [ ! -d "$insta_mount_point" ]; then if [ ! -d "$insta_mount_point" ]; then
echo "Creating mount point directory..." echo "Creating mount point directory..."
mkdir -p "$insta_mount_point" mkdir -p "$insta_mount_point"
fi fi
if ! $is_local_nas; then if ! $is_local_nas; then
if ! check_smb_mount; then if ! check_smb_mount; then
echo "Mounting SMB share..." echo "Mounting SMB share..."
/sbin/mount_smbfs "smb://janolehuebner:$(pass sudo-lana 2>/dev/null)@$insta_share_on_nas" "$insta_mount_point" /sbin/mount_smbfs "smb://janolehuebner:$(pass sudo-lana 2>/dev/null)@$insta_share_on_nas" "$insta_mount_point"
fi fi
if ! check_smb_mount; then if ! check_smb_mount; then
echo "Failed to mount SMB share. Exiting." echo "Failed to mount SMB share. Exiting."
return 1 return 1
fi fi
fi fi
cd "$insta_mount_point/$insta_path_on_nas" || return 1 cd "$insta_mount_point/$insta_path_on_nas" || return 1
if [[ ${#user_list[@]} -eq 0 ]]; then if [[ ${#user_list[@]} -eq 0 ]]; then
user_list=("${insta_default_users[@]}") user_list=("${insta_default_users[@]}")
fi fi
local cmd=(uvx --with browser_cookie3 instaloader -b Safari -B "$insta_cookiefile" "${user_list[@]}" --fast-update) local cmd=(uvx --with browser_cookie3 instaloader -b Safari "${user_list[@]}" --fast-update)
if $stories_only; then if $stories_only; then
cmd+=(--stories --no-profile-pic --no-posts) cmd+=(--stories --no-profile-pic --no-posts)
else else
cmd+=(--stories --reels) cmd+=(--stories --reels)
fi fi
"${cmd[@]}" "${cmd[@]}"
if ! $is_local_nas; then if ! $is_local_nas; then
echo "Unmounting SMB share..." echo "Unmounting SMB share..."
sleep 3 sleep 3
/sbin/umount -f "$insta_mount_point" /sbin/umount -f "$insta_mount_point"
fi fi
cd "$cwd" cd "$cwd"
} }