serverhost

fix
This commit is contained in:
Lucas Faber authored and Lucas Vivohost committed 2026-09-14 09:20:47 +02:00
1 parent 24736d0577
commit 84dfdf5210
38 files changed
+3146

No files matched your search

@@ -0,0 +1,44 @@
#!/bin/bash
BASE="RecepiesLucas"
find "$BASE" -type d | while read -r dir; do
# Collect all recipe.json.v* files in the directory
files=("$dir"/recipe.json.v*)
# Skip if no matching files
[ -e "${files[0]}" ] || continue
# Filter only files modified on Feb 2
feb2_files=()
for f in "${files[@]}"; do
# Check modification date (format: YYYY-MM-DD)
file_date=$(date -r "$f" +%Y-%m-%d)
if [ "$file_date" = "2026-02-02" ]; then
feb2_files+=("$f")
fi
done
# Skip if no Feb 2 files
[ ${#feb2_files[@]} -gt 0 ] || continue
# Sort by timestamp and keep earliest
# Sort by numeric suffix at the end of the filename and keep earliest
IFS=$'\n' sorted=($(for f in "${feb2_files[@]}"; do
# Extract the numeric suffix after .v
version="${f##*.v}" # removes everything up to last .v
echo "$version $f"
done | sort -n | awk '{ $1=""; sub(/^ /,""); print }'))
earliest="${sorted[0]}"
echo "Keeping $earliest in $dir"
mv "$earliest" "$dir/recipe.json"
# Delete the rest
for f in "${sorted[@]:1}"; do
echo "Deleting $f"
rm "$f"
done
done
+24
View File
@@ -0,0 +1,24 @@
-----BEGIN CERTIFICATE-----
MIIEAzCCAuugAwIBAgIUEfJJRe6MkMf0S8EF7iLWX19xIQQwDQYJKoZIhvcNAQEL
BQAwgZAxCzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMRAwDgYDVQQH
DAdUb3BDaXR5MQwwCgYDVQQKDANUUkQxDzANBgNVBAsMBkFTTQhMTTEnMCUGA1UE
AwweaHR0cHM6Ly9zb21lb25lc2xpbnV4LmRkbnMubmV0MRIwEAYJKoZIhvcNAQkB
FgNsbG0wHhcNMjIxMTMwMTkwNzM2WhcNMjMxMTMwMTkwNzM2WjCBkDELMAkGA1UE
BhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxEDAOBgNVBAcMB1RvcENpdHkxDDAK
BgNVBAoMA1RSRDEPMA0GA1UECwwGQVNNCExNMScwJQYDVQQDDB5odHRwczovL3Nv
bWVvbmVzbGludXguZGRucy5uZXQxEjAQBgkqhkiG9w0BCQEWA2xsbTCCASIwDQYJ
KoZIhvcNAQEBBQADggEPADCCAQoCggEBAOdFwLXWCbwQbhVU9SdjveXkinvDdwOO
+J0rFftyh8zua0Lgr0+M5eMBrX5Y6BDtFnJXS9b+qGxN16w+YhDXgK/GaTWC1z/x
gIBJAdjfPhG2Ip1oDWkZshq97+7VzYRpMcujpdU+h6FCFg8aRcTQJpKrD+nY0BzF
eWBL6kexFKdzUVM4icasWcUBMNZpduTbzAtunXtiMJPB1rLQsOAzwf1Hpg9gBAn9
g4cUK0MV7FkwZBXtYOxvcHIlnWUw6jZi8ECgFDmrYU5DK8HQc8L1aKhxnOCYOLjK
Gn7lPriMRaIYVdYQeAzP7iHJGmicEZ0ocwdGbbrRjIsYsKVrMYk6HgkCAwEAAaNT
MFEwHQYDVR0OBBYEFFc1jL0qmotgw719YjMB4N7znfTuMB8GA1UdIwQYMBaAFFc1
jL0qmotgw719YjMB4N7znfTuMA8GA1UdEwEB/wQFMAMBAf8wDQYJKoZIhvcNAQEL
BQADggEBAI7nkU+GXWbN8ceSRe9W0XNffa284ByfgdoLOCVLdgyIs1kONAMxJHH8
3ky8ceL30SGbqkv9ObOTBZRPtlDLLMbPSiVnaB0BszFrnqvZUkHTH+FoXr5dO1Ol
N5MLBSK/fMGT+wRAeZHdFfsYI/tUnhZZKQ/zFqFnLzjpzTnqTsLzoPkLYnuXBd6y
x6ReLUohf5d00zPLeOUOyiHUvGEsgn640eH3OXx7arcKSV2fDErqDXtzs20fkJ01
/hSDsDUzbh9ObwfkHLRFJcf1gZ40GrWVRASenHHBIEjpVk0UfIioai8zrbJdbGEN
LifpzGYkEiQlxHEg9+R6cKAlW7Cgvas=
-----END CERTIFICATE-----
+49
View File
@@ -0,0 +1,49 @@
#!/bin/bash
names_container=("lucas" "multimedia" "mimi")
clean_versions() {
VERSION_DIRS=("Music" "Pictures" "Stuff" "SW")
for dir in ${VERSION_DIRS[@]}; do
if [ -d /nextcloud/nextcloud-data/lucas/files_versions/${dir} ]; then
echo "Delete /nextcloud/nextcloud-data/lucas/files_versions/${dir}? (y/*)"
read -n 4 choice
if [[ "${choice}" == "y" ]]; then
echo "Delete"
rm -dr /nextcloud/nextcloud-data/lucas/files_versions/${dir}
else
echo "Skip"
fi
else
echo "${dir} not present - skipping"
fi
done
}
clean_trashbin() {
container=("avi" "mkv" "mp4" "m4v" "srt")
IFS=$'\n'; set -f
find /nextcloud/nextcloud-data/multimedia/files_trashbin/files/ -name *\.* -delete
for name in ${names_container[@]}; do
for cont in ${container[@]}; do
FILE_ARR=("${FILE_ARR[@]}" $(find /nextcloud/nextcloud-data/${name}/files_trashbin/files/ -type f -name "*${cont}*"))
done
done
if [ ${#FILE_ARR[@]} -eq 0 ]; then
echo "No Media Containers Present"
return
fi
for file in ${FILE_ARR[@]}; do
echo "Delete $( echo $file | rev | cut -f1 -d'/' | rev)"
rm "${file}"
done
}
check_root(){
if [ $(id -u) -ne 0 ]; then
echo "Execute as root: $(id)"
exit
fi
}
check_root
service apache2 stop
clean_versions
clean_trashbin
service apache2 start
+53
View File
@@ -0,0 +1,53 @@
#!/bin/bash
date="$(date +"%m%d%H")"
> /home/lucas/.LOG/log_occ_mimi_$date.log
> /home/lucas/.LOG/log_occ_lucas_$date.log
STARTTIME=$(date +"%T")
echo "Starttime: $STARTTIME"
sudo service apache2 stop
ret1="$(sudo -u www-data php /nextcloud/nextcloud/occ files:cleanup)"
echo $ret1
{ sudo -u www-data php /nextcloud/nextcloud/occ files:scan -vvv mimi >> /home/lucas/.LOG/log_occ_mimi_$date.log ; }& PID1=$!
{ sudo -u www-data php /nextcloud/nextcloud/occ files:scan -vvv lucas >> /home/lucas/.LOG/log_occ_lucas_$date.log ; }& PID2=$!
{ sudo -u www-data php /nextcloud/nextcloud/occ files:scan -vvv multimedia >> /home/lucas/.LOG/log_occ_multi_$date.log ; }& PID3=$!
wait $PID3
echo "Multimedia finished" >> /home/lucas/.LOG/log_occ_multi_$date.log
wait $PID2
echo "Mimi finished" >> /home/lucas/.LOG/log_occ_mimi_$date.log
wait $PID1
echo "Lucas finished" >> /home/lucas/.LOG/log_occ_mimi_$date.log
ret2="$(cat /home/lucas/.LOG/log_occ_mimi_$date.log)"
echo $ret2
ret3="$(cat /home/lucas/.LOG/log_occ_lucas_$date.log)"
echo $ret3
ret4="$(sudo -u www-data php /nextcloud/nextcloud/occ check)"
echo $ret4
sudo service apache2 start
sudo -u www-data php /nextcloud/nextcloud/occ maintenance:mode --on
ret5="$(sudo -u www-data php /nextcloud/nextcloud/occ maintenance:mimetype:update-db)"
echo $ret5
ret6="$(sudo -u www-data php /nextcloud/nextcloud/occ maintenance:update:htaccess)"
echo $ret6
ret7="$(sudo -u www-data php /nextcloud/nextcloud/occ maintenance:mimetype:update-js)"
echo $ret7
sudo -u www-data php /nextcloud/nextcloud/occ maintenance:mode --off
ENDTIME=$(date +%T)
#mail -s "Automated Servermessage - Backup" lucas-f@live.at << MSG_BODY_HERE
#Nextcloud Maintanence Complete:
printf "$ret1
$ret2
$ret3
$ret4
$ret5
$ret6
$ret7
Start: $STARTTIME
End: $ENDTIME
" >> /home/lucas/.LOG/log_occ_scan.log
#MSG_BODY_HERE
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
#SSH
cat /var/log/auth.log | grep sshd | grep -E "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | grep ": Failed"| cut -f1-3,6,7,11 -d' '
cat /var/log/auth.log | grep sshd | grep -E "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b" | grep "Accepted" | cut -f1-3,6,7,11 -d' '
#NextCloud
cat /nextcloud/nextcloud/access.log | grep -v dummy | cut -f1 -d' ' | sort | uniq -c
cat /nextcloud/nextcloud/access.log | grep -v dummy | cut -f2 -d'"' | cut -f1 -d' ' | sort | uniq -c
File diff suppressed because it is too large. Load diff
+186
View File
@@ -0,0 +1,186 @@
#!/bin/bash
date="$(date +"%m%d%H")"
echo "Start Backup" > /home/lucas/.LOG/log_backup_$date.log
find /home/lucas/.LOG/log_backup_* -mtime +12 -type f -delete
STARTTIME=$(date +"%T")
echo "Starttime: $STARTTIME"
sleep 2
#BACKUP=true
BACKUP_DATA=false
BACKUP_CAL=true
BACKUP_THESIS=false
if [ "$1" == "-thesis" ]; then
BACKUP_DATA=false
BACKUP_CAL=false
BACKUP_THESIS=true
echo "Backup thesis only"
fi
if $BACKUP_DATA; then
old_bak="$(find /backup/backup_* -mtime +83 -type f)"
find /backup/backup_* -mtime +83 -type f -delete
old_doc_bak="$(find /backup/backup_documents_* -mtime +31 -type f)"
find /backup/backup_documents_* -mtime +31 -type f -delete
if [ -d /nextcloud/nextcloud-data/lucas/files/Dokumente ]; then
{ tar -zcvf /backup/backup_documents_lucas$(date -d "today" +"%m%d").tgz /nextcloud/nextcloud-data/lucas/files/Dokumente ; echo "Lucas Documents: $?" >> /home/lucas/.LOG/log_backup_$date.log ; }& PID_DOC_LUC=$!
else
PID_DOC_LUC=0
fi
if [ -d /nextcloud/nextcloud-data/mimi/files/Dokumente ]; then
{ tar -zcvf /backup/backup_documents_mimi$(date -d "today" +"%m%d").tgz /nextcloud/nextcloud-data/mimi/files/Dokumente ; echo "Mimi Documents: $?" >> /home/lucas/.LOG/log_backup_$date.log ; } & PID_DOC_MIMI=$!
else
PID_DOC_MIMI=0
fi
PIC_Overwrite=false
if [ $(find /backup/backup_pictures_* -type f | wc -l) -lt 1 ] || [ $(find /backup/backup_pictures_* -mtime -13 -type f | wc -l) -lt 1 ] || $PIC_Overwrite; then
printf "Backup Pictures because it's the %s\n " "$(date -d 'today' +'%d.%m')" >> /home/lucas/.LOG/log_backup_$date.log
printf "Today: %s\n" "$(date -d "today" +"%d")"
old_pic_bak="Remove old Pictures: $(find /backup/backup_pictures_* -mtime +50 -type f)"
find /backup/backup_pictures_* -mtime +30 -type f -delete
{ tar -zcvf /backup/backup_pictures_$(date -d "today" +"%m%d").tgz /nextcloud/nextcloud-data/lucas/files/Media/Pictures ; echo "Lucas Pictures: $?" >> /home/lucas/.LOG/log_backup_$date.log ; } & PID_PIC=$!
printf "Backup Music because it's the %s\n " "$(date -d 'today' +'%d.%m')" >> /home/lucas/.LOG/log_backup_$date.log
printf "Today: %s\n" "$(date -d "today" +"%d")"
old_music_bak="Remove old Pictures: $(find /backup/backup_pictures_* -mtime +50 -type f)"
find /backup/backup_music_* -mtime +30 -type f -delete
{ tar -zcvf /backup/backup_music_$(date -d "today" +"%m%d").tgz /nextcloud/nextcloud-data/lucas/files/Media/Music/Musik ; echo "Lucas Music: $?" >> /home/lucas/.LOG/log_backup_$date.log ; } & PID_MUSIC=$!
pics=true
else
echo "No Picture and Music Backup planed" >> /home/lucas/.LOG/log_backup_$date.log
fi
wait $PID_DOC_MIMI
echo "Documents Mimi finished" >> /home/lucas/.LOG/log_backup_$date.log
wait $PID_DOC_LUC
echo "Documents Lucas finished" >> /home/lucas/.LOG/log_backup_$date.log
if [ $pics ]; then
wait $PID_PIC
echo "Picture Backup Finished" >> /home/lucas/.LOG/log_backup_$date.log
wait $PID_MUSIC
echo "Music Backup Finished" >> /home/lucas/.LOG/log_backup_$date.log
fi
echo "Backup Finished" >> /home/lucas/.LOG/log_backup_$date.log
fi
ENDTIME=$(date +%T)
if $BACKUP_CAL; then
old_cal_bak="$(find /backup/backup_calender_* -mtime +31 -type f)"
find /backup/backup_calender_* -mtime +31 -type f -delete
backup_cal_OC="/backup/backup_calender_NC_$(date -d "today" +"%m%d").ics"
backup_cal_geb="/backup/backup_calender_geb_$(date -d "today" +"%m%d").ics"
backup_cal_home="/backup/backup_calender_home_$(date -d "today" +"%m%d").ics"
#export WGETRC="/home/lucas/Documents/Dokumente/Projekte/Server/www/wgetrc"
wget --no-check-certificate -O "$backup_cal_OC" "https://someoneslinux.ddns.net/remote.php/dav/calendars/lucas/nextcloud?export"
if [ $? -eq 0 ]; then CAL_RET1="nextCloud Calender backup Successfull"; fi
wget --no-check-certificate -O "$backup_cal_geb" "https://someoneslinux.ddns.net/remote.php/dav/calendars/lucas/geburtstage?export"
if [ $? -eq 0 ]; then CAL_RET2="Geburtstags Calender backup Successfull"; fi
wget --no-check-certificate -O "$backup_cal_home" "https://someoneslinux.ddns.net/remote.php/dav/calendars/lucas/haushalt?export"
if [ $? -eq 0 ]; then CAL_RET3="Haushalts Calender backup Successfull"; fi
old_cont_bak="$(find /backup/backup_contacts_* -mtime +31 -type f)"
find /backup/backup_calender_* -mtime +31 -type f -delete
backup_contacts_phone="/backup/backup_contacts_ContactsPhone_$(date -d "today" +"%m%d").vcf"
backup_email_addr="/backup/backup_contacts_EmailAddressen_$(date -d "today" +"%m%d").vcf"
wget --no-check-certificate -O "$backup_contacts_phone" "https://someoneslinux.ddns.net/remote.php/dav/addressbooks/users/lucas/phonecontacts-1?export"
if [ $? -eq 0 ]; then CON_RET1="nextCloud Contacts Phone backup Successfull"; fi
wget --no-check-certificate -O "$backup_email_addr" "https://someoneslinux.ddns.net/remote.php/dav/addressbooks/users/lucas/emailadressen-1?export"
if [ $? -eq 0 ]; then CON_RET2="NextCloud Contacts Email backup Successfull"; fi
fi
if $BACKUP_THESIS;then
old_thesis_bak="$(find /backup/backup_thesis_* -mtime +31 -type f)"
if [ -d /nextcloud/nextcloud-data/lucas/files/Dokumente/Studium/Master/Thesis/ ]; then
{ tar -zcvf /backup/backup_thesis_lucas$(date -d "today" +"%y%m%d_%H%M").tgz /nextcloud/nextcloud-data/lucas/files/Dokumente/Studium/Master/Thesis/ ; echo "Lucas Thesis: $?" >> /home/lucas/.LOG/log_backup_$date.log ; }& PID_THESIS_LUC=$!
else
PID_THESIS_LUC=0
fi
wait $PID_THESIS_LUC
echo "Thesis finished" >> /home/lucas/.LOG/log_backup_$date.log
if [ ! -d /backup/bkp ] ; then mkdir /backup/bkp; fi
last=-1; find /backup/ -type f -name '*thesis*' -printf '%f\0' | sort -nz |
while read -d '' i; do
s=$(stat -c '%s' "/backup/$i");
[[ $s = $last ]] && rm "/backup/$i";
last=$s;
done
#find /backup/ -type f -printf "%s %p\n" | grep "thesis" | sort -n | uniq -d --check-chars=20 | awk '{ print $2 }' | xargs mv -t /backup/bkp/
find /backup/ -maxdepth 1 -type f -name "*thesis*" -mtime +31 -type f -delete
#mv /backup/bkp/* /backup
fi
if [ "$old_bak" == "" ]; then
old_bak="Nothing older than 83 Days removed"
fi
if [ "$old_thesis_bak" == "" ]; then
old_thesis_bak="No Thesis Documents removed"
fi
if [ "$old_doc_bak" == "" ]; then
old_doc_bak="No Documents removed"
fi
if [ "$old_pic_bak" == "" ]; then
old_pic_bak="No Pictures removed"
fi
if [ "$old_music_bak" == "" ]; then
old_music_bak="No Pictures removed"
fi
if [ "$old_cal_bak" == "" ]; then
old_cal_bak="No Calenders removed"
fi
if [ "$old_cont_bak" == "" ]; then
old_cont_bak="No Contacts removed"
fi
IFS=$'\n'; set -f
data_dev=($(df -h | grep "/dev/sd[a-f]" | sed 's/ \+/ /g' | cut -f1 -d' '))
unset IFS; set +f
osspace=""
Out="";
for ((i=0;i<${#data_dev[@]};i++)); do
device="$(df -h "${data_dev[$i]}" | sed 's/ \+/ /g' | tail -1 | cut -f6 -d' ')"
if [ "$device" != "/" ]; then
device="/$(echo $device | rev | cut -f1 -d'/' |rev):"
else
device="/root:"
fi
osspace="$(df -h "${data_dev[$i]}" | tr -d '%' | awk 'NR==2 { printf "Total: %sB, Used: %sB, Free: %sB ... %spercent used\n",$2,$3,$4,$5; }')"
tab_num=$((3 - ${#device} / 8))
Out="$Out${device}"
for ((j=0;j<$tab_num;j++));do Out="$Out\t"; done
Out="$Out$osspace\n"
done
if [[ $BACKUP_DATA == true || $BACKUP_CAL == true ]]; then
mail -s "Automated Servermessage - Backup" lucas-f@live.at << MSG_BODY_HERE
Remove Old Files:
$old_doc_bak
Remove Really Old Files:
$old_bak
Document Backup:
$(cat /home/lucas/.LOG/log_backup_$date.log | grep Documents)
Picture Backup:
$(if [ $pics ]; then printf "%s %s\n%s %s\n" "$old_pic_bak" "$(cat /home/lucas/.LOG/log_backup_$date.log | grep Pictures)" "$old_music_bak" "$(cat /home/lucas/.LOG/log_backup_$date.log | grep Music)"; else printf "No Picture and Music Backup necessary."; fi)
Remove Old Calenders:
$old_cal_bak
Calender Backup:
$CAL_RET1
$CAL_RET2
$CAL_RET3
Remove Old Contacts:
$old_cont_bak
Contacts Backup:
$CON_RET1
$CON_RET2
Directory:
$(printf "$Out")
$(ls -lh /backup/)
Start: $STARTTIME
End: $ENDTIME
MSG_BODY_HERE
fi
echo "Endtime: $ENDTIME"
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
backup_cal_blumen="/home/lucas/calender_blumen_$(date -d "today" +"%m%d").ics"
export WGETRC="/home/lucas/.wgetrc"
wget -q --no-check-certificate -O "$backup_cal_blumen" "https://someoneslinux.ddns.net/remote.php/dav/calendars/lucas/blumen?export"
if [ $? -eq 0 ]; then
echo "Download Succesfull"
fi
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
/usr/bin/chown -R tv-bitch:tv-bitch /torrent/multimedia/Filme
+170
View File
@@ -0,0 +1,170 @@
#!/bin/bash
IFS=$'\n'; set -f
STUFF="/torrent/multimedia/Filme/New/"
ASSUMEYES=false
FILTER_MODE=false
FILE_PATH="/torrent/complete/"
usage() {
printf "Usage:
-y\ty Mode
-m\tmega Mode
-v\tCopy to ~/Videos
-help\tDisplay this\n"
}
get_config() {
while [[ ${1:0:1} == - ]]; do
echo "Param: $1"
[[ $1 == -help ]] && {
echo "Help"
usage;
exit;
};
[[ $1 == -v ]] && {
echo "Dest: Videos"
STUFF="/data/Videos/"
shift 1
continue
};
[[ $1 == -y ]] && {
echo "y Mode"
ASSUMEYES=true
shift 1
continue
};
[[ $1 == -m ]] && {
echo "mega Mode"
FILE_PATH="/torrent/mega/"
shift 1
continue
};
[[ $1 == -l ]] && {
echo "List Mode"
LIST_MODE=true
shift 1
continue
};
[[ $1 == -f ]] && {
echo "Filter Mode"
FILTER_MODE=true
shift 1
continue
};
echo "Parameter $1 discarded"
usage
exit
done
}
get_config "$@"
LIST=($(sudo /home/lucas/scripts/serverhost/deluge_user_cmd.sh ls ${FILE_PATH}))
if [ ${#LIST[@]} -eq 0 ]; then
echo "Nothing to Copy/Delete"
exit
fi
if [ "${LIST_MODE}" == "true" ]; then
for i in "${!LIST[@]}"; do
files=${LIST[$i]}
echo "Copy? ${files} (y/*)"
read -n 10 ans
if [ "$ans" != "y" ]; then
echo "Dont copy $files"
unset 'LIST[i]'
fi
done
echo "NEW LIST:"
echo "${LIST[*]}"
fi
if [ ${#LIST[@]} -eq 0 ]; then
echo "Nothing to Copy/Delete"
exit
fi
if [ "${ASSUMEYES}" == "false" ]; then
echo "Copy? (y/*)"
echo "${LIST[*]}"
read -n 10 ans
else
echo "Copy to Films:"
echo "${LIST[*]}"
ans="y"
fi
if [ "$ans" == "y" ]; then
for files in ${LIST[@]}; do
#sudo /home/lucas/scripts/serverhost/deluge_user_cmd.sh cp -dr ${FILE_PATH}$(printf "%q" "$files") "${STUFF}"
sudo /home/lucas/scripts/serverhost/deluge_user_cmd.sh cp -dr --no-preserve=mode ${FILE_PATH}${files} ${STUFF}
if [ $? -ne 0 ]; then fail=true; echo "Copy Failure"; exit; fi
done
printf "Torrents Copied\n"
else
printf "Nothing Copied\n"
fi
if [ "${ASSUMEYES}" == "false" ]; then
echo "Rename? (y/*)"
echo "${LIST[*]}"
read -n 10 ans
else
ans="y"
fi
printf "Change Ownership\n"
sudo /home/lucas/Documents/Dokumente/Projekte/Server/scripts/serverhost/chown_tv.sh
if [ "$ans" == "y" ]; then
for files in ${LIST[@]}; do
echo "Rename $files"
filepath="${STUFF}${files}"
if [ -e "${filepath}" ]; then
echo "${filepath} exists"
sudo /home/lucas/scripts/serverhost/tvbitch_user_cmd.sh chmod -R 777 "${filepath}"
/home/lucas/.venv_general/bin/python3 /home/lucas/scripts/rename_episodes.py -d -rep -p "${filepath}"
else
echo "${filepath} neither Directory nor regular file"
fi
done
printf "Rename Complete\n"
else
printf "Nothing Renamed\n"
fi
if [ "${FILTER_MODE}" == "true" ]; then
for files in ${LIST[@]}; do
echo "Filter $files"
filepath="${STUFF}${files}"
if [ -e "${filepath}" ]; then
echo "Filter Video? (y/*)"
echo "${files}"
read -n 10 ans
if [ "$ans" == "y" ]; then
echo "Filter ${files}"
sudo /home/lucas/scripts/serverhost/tvbitch_user_cmd.sh chmod -R 777 "${filepath}"
if /home/lucas/.venv_general/bin/python3 /home/lucas/scripts/ffmpeg_handling.py filter-audio ${filepath} -o \
"${STUFF}_${files}" ; then
echo "Filter sucessfull"
mv "${STUFF}_${files}" "${STUFF}${files}"
fi
fi
else
echo "${filepath} neither Directory nor regular file"
fi
done
printf "Filter Complete\n"
fi
if [ "${ASSUMEYES}" == "false" ]; then
echo "Delete? (y/*)"
echo "${LIST[*]}"
read -n 10 ans
else
ans="y"
fi
if [ "$ans" == "y" ]; then
for files in ${LIST[@]}; do
echo "Delete $files"
sudo /home/lucas/scripts/serverhost/deluge_user_cmd.sh rm -dr ${FILE_PATH}${files}
done
printf "Torrents Removed\n"
else
printf "Nothing Removed\n"
fi
unset IFS; set +f
syncNC -m -del
+394
View File
@@ -0,0 +1,394 @@
#!/bin/bash
exec 2>/dev/null
if [ "$TERM" != "xterm-256color" ]; then
export TERM="xterm-256color"
fi
DEL_CONSOLE_CMD="deluge-console connect 127.0.0.1:53032;"
cond=""
norm="$'\e[0m'"
red="$'\e[1;31m'"
if [ "$(hostname)" == "serverhost" ]; then
duser="sudo /home/lucas/scripts/deluge_user_cmd.sh"
elif [ "$(hostname)" == "quiethost" ]; then
duser=""
fi
STARS_HANDY="************************"
stars() {
width=$(tput cols)
counter=1
while [ $counter -le $width ]; do
printf "*"
((counter++))
done
}
out=""
SEARCH_MODE=false
SLIM_MODE=false
STATIC_MODE=false
DOWN=""
HANDY_MODE=false
NAMES_MODE=false
RM_MODE=false
SLEEP_TIME=1
DOWNLOADING="ADCFEGCLG"
RMS_MODE=false
NORMAL_MODE=true
GREP_ARR=()
GREPV_ARR=()
get_config() {
while [[ ${1:0:1} == - ]]; do
echo "Param: $1"
[[ $1 == -t ]] && {
if [ "$2" == "" ] ; then echo "Too few arguments"; usage; exit; fi
echo "Search Torrent"
SLEEP_TIME="$2"
shift 2;
continue;
};
[[ $1 == -s ]] && {
if [ "$2" == "" ] ; then echo "Too few arguments"; usage; exit; fi
echo "Search Torrent"
SEARCH_MODE=true
NORMAL_MODE=false
SEARCH="$2"
shift 2;
continue;
};
[[ $1 == -detail ]] && {
if [ "$2" == "" ] ; then echo "Too few arguments"; usage; exit; fi
echo "Detail Torrent"
DETAIL_MODE=true
NORMAL_MODE=false
SEARCH="$2"
shift 2;
while [[ ${1:0:1} == - ]]; do
[[ $1 == -g ]] && {
shift 1
while [[ ${1:0:1} != - ]]; do
if [ "$1" == "" ]; then break; fi
GREP_ARR+=("$1")
shift 1
continue
done
}
[[ $1 == -v ]] && {
shift 1
while [[ ${1:0:1} != - ]]; do
if [ "$1" == "" ]; then break; fi
GREPV_ARR+=("$1")
shift 1
continue
done
}
done
break
};
[[ $1 == -slim ]] && {
echo "Slim Mode"
SLIM_MODE=true
NORMAL_MODE=false
shift 1;
continue;
};
[[ $1 == -ON ]] && {
echo "Show only actual Downloading"
DOWNLOADING="Down Speed: 0.0 KiB/s"
shift 1;
continue;
};
[[ $1 == -on ]] && {
echo "Show only State Downloading"
DOWN="Speed"
shift 1;
continue;
};
[[ $1 == -rm ]] && {
echo "RM Mode"
RM_MODE=true
NORMAL_MODE=false
shift 1;
continue;
};
[[ $1 == -rms ]] && {
if [ "$2" == "" ] ; then echo "Too few arguments"; usage; exit; fi
RMS_SEARCH="$2"
echo "RMS Mode"
RMS_MODE=true
NORMAL_MODE=false
shift 2;
continue;
};
[[ $1 == -static ]] && {
echo "Static Mode"
STATIC_MODE=true
shift 1;
continue;
};
[[ $1 == -names ]] && {
echo "Names Mode"
NAMES_MODE=true
NORMAL_MODE=false
shift 1;
continue;
};
[[ $1 == -handy ]] && {
echo "Handy Mode"
HANDY_MODE=true
NORMAL_MODE=false
shift 1;
continue;
};
[[ $1 == -help ]] && {
usage;
exit;
};
echo "Parameter $1 discarded"
exit
done
}
usage() {
printf "Usage:
-names\t\t\tfor display of all names and IDs
-slim\t\t\tminimal display of torrents
-on\t\t\tShow only State Downloading Torrents
-ON\t\t\tShow only actual Downloading Torrents
-static\t\t\tfor one time display of all deluge modes
-handy\t\t\tfor custom smartphone display
-rm\t\t\tremove Torrents
-s <search>\t\tSearch for one Torrent (Name or ID)
-detail <search>\tDeatiled Depiction of one Torrent
-g <param>\tParameters to grep
-v <param>\tParameters to grep -v
-help\t\t\tdisplay this help\n"
}
print_string() {
width=$(($(tput cols)/2-${#1}/2))
counter=1
while [ $counter -le $width ]; do
printf " "
((counter++))
done
printf "%s\n" "$1"
}
normal_deluge() {
${duser} ${DEL_CONSOLE_CMD} info | tr '\n' ';' | sed 's/\[\([~,#]*\)\];/\[\1\]\n/g' | grep -v "${DOWNLOADING}" | grep "${DOWN}" | tr ';' '\n' | sed 's/Size: /\nSize: /g' | sed 's/ Ratio/\nRatio/g' | sed 's/Up Speed/\nUp Speed/g'| sed 's/ETA:/\nETA:/g'| grep 'Name:\|Progress:\|State:\|Size:\|ETA:' | tr '\n' ' ' | sed 's/State/\nState/g' | sed 's/Progress/\nProgress/g' | sed 's/Name/\nName/g' | sed 's/Size/\nSize/g' | sed 's/Progress: \(.*%\)/\\\e[33mProgress: \1\\\e[0m/g' | sed -e "s/Down Speed:\(.*\/s\)/\\\e[31m Speed: \1\\\e[0m/g"
}
slim_deluge() {
${duser} ${DEL_CONSOLE_CMD} info | tr '\n' ';' | sed 's/\[\([~,#]*\)\];/\[\1\]\n/g' | grep -v "${DOWNLOADING}" | grep "${DOWN}" | tr ';' '\n' | sed 's/Down Speed:/\nDown Speed:/g' | sed 's/Up Speed/\nUp Speed/g' | sed 's/ETA/\nETA/g'| sed 's/\[.*\]//g' | grep 'Progress\|Name\|Down Speed\|ETA'| tr --delete '\n' | sed 's/Name:/\nName:/g' | sed 's/Progress: \(.*%\)/ \\\e[33m\1\\\e[0m/g' | sed -e "s/Down Speed:\(.*\/s\)/\tSpeed: \\\e[31m\1\\\e[0m/g" | sort
}
search_deluge() {
${duser} ${DEL_CONSOLE_CMD} info ${SEARCH}
}
detail_deluge() {
STRING=$(${duser} ${DEL_CONSOLE_CMD} info -v ${SEARCH} | grep "Priority" | sed 's/Progress: \(.*%\)/Progress: \\\e[31m\1\\\e[0m/g' | sed 's/Priority: Normal/Normal\n/g' | sed 's/Priority: High/High\n/g' | sed 's/Priority: Highest/Highest\n/g')
STRING=$(${duser} ${DEL_CONSOLE_CMD} info -v ${SEARCH} | grep "Priority" | sed 's/Progress: \(.*%\)/Progress: \\\e[31m\1\\\e[0m/g')
for (( i=0; i<${#GREP_ARR[*]};i++ )); do
STRING="$(printf "%s" "${STRING}" | grep "${GREP_ARR[$i]}")"
done
for (( i=0;i<${#GREPV_ARR[*]};i++ )); do
STRING="$(printf "%s" "${STRING}" | grep -v "${GREPV_ARR[$i]}")"
done
printf "%s" "${STRING}"
}
handy_deluge() {
STRING=$(${duser} ${DEL_CONSOLE_CMD} info | tr '\n' ';' | sed 's/\[\([~,#]*\)\];/\[\1\]\n/g' | grep -v "${DOWNLOADING}" | grep "${DOWN}" | tr ';' '\n' | sed 's/Size: /\nSize: /g' | sed 's/ Ratio/\nRatio/g' | sed 's/Up Speed/\nUp Speed/g'| sed 's/ETA:/\nETA:/g'| grep 'Name:\|State:\|Size:\|ETA:' | tr '\n' ' ' | sed 's/State/\nState/g' | sed 's/Progress/\nProgress/g' | sed 's/Name/\nName/g' | sed 's/Size/\nSize/g')
if [ "${STRING}" == "" ]; then
printf "%s\n" "${STARS_HANDY}"
printf "\t\t\t\t\t\t No Torrents in deluged client\n"
printf "%s\n" "${STARS_HANDY}"
else
printf "%s\n" "${STARS_HANDY}"
printf "\t\t\t\t\t\tCustom Deluge Client\n"
printf "%s\n" "${STARS_HANDY}"
printf "%s\n" "${STRING}"
fi
}
deluge_rms() {
if [ "$1" != "" ]; then
names=($(${duser} ${DEL_CONSOLE_CMD} info | grep -v "State: Downloading\|ID:" | grep -v "Queued" | grep -v "Paused" | grep -B2 "State: " | grep Name | sed 's/ */_/g' | sed 's/Name: //g'))
ID=($(${duser} ${DEL_CONSOLE_CMD} info | grep -v "State: Downloading" | grep -v "Queued" | grep -v "Paused" | grep -B2 "State: " | grep 'ID: ' | sed 's/ID: //g'))
STATE=($(${duser} ${DEL_CONSOLE_CMD} info | grep -v "State: Downloading" | grep -v "Queued" | grep -v "Paused" | sed 's/Up Speed/\nUp Speed/g' | grep "State: " | sed 's/ *//g' | sed 's/State://g'))
else
names=($(${duser} ${DEL_CONSOLE_CMD} info | grep -v "State: Downloading\|ID:" | grep -v "Paused" | grep -B2 "State: " | grep Name | sed 's/ */_/g' | sed 's/Name: //g'))
ID=($(${duser} ${DEL_CONSOLE_CMD} info | grep -v "State: Downloading" | grep -v "Paused" | grep -B2 "State: " | grep 'ID: ' | sed 's/ID: //g'))
STATE=($(${duser} ${DEL_CONSOLE_CMD} info | grep -v "State: Downloading" | grep -v "Paused" | sed 's/Up Speed/\nUp Speed/g' | grep "State: " | sed 's/ *//g' | sed 's/State://g'))
fi
#${DEL_CONSOLE_CMD} info | grep 'Name: ' | sed 's/ */_/g' | sed 's/Name: //g'))
if [ ${#names[@]} -eq 0 ]; then
stars
print_string "No Finished Torrents in deluged client"
stars
else
printf "Which Torrent shall we eliminate?(Enter leading number)\n"
echo ${names[1]}
for ((i = 0 ; i < ${#names[@]} ; i ++)); do
printf "%s: %s\n" "$i" "${names[$i]}"
printf "State: %s\n" "${STATE[$i]}"
done
read -t 10 -n 4 choice1
if [ $choice1 -le ${#names[@]} 2>/dev/null ]; then
printf "Remove %s\n" "${names[$choice1]}"
printf "Remove Data too?(y/q/*)(q for quit)\n"
read -t 10 -n 2 choice2
if [ "$choice2" == "y" ]; then
RM_DATA="--remove_data"
elif [ "$choice2" == "q" ]; then
echo "Cancell Removal"
return
else
RM_DATA=""
fi
${duser} ${DEL_CONSOLE_CMD} rm ${RM_DATA} ${ID[$choice1]}
if [ $(${duser} ${DEL_CONSOLE_CMD} info | grep -c "Name: ") -eq $((${#names[@]} - 1)) ]; then
printf "\e[32mDeletion Successfull\e[0m\n"
fi
elif [ "${choice1}" == "ALL" ]; then
printf "Remove Data too?(y/*)\n"
read -t 10 -n 2 choice2
if [ "$choice2" == "y" ]; then
RM_DATA="--remove_data"
else
RM_DATA=""
fi
for ((i = 0 ; i < ${#names[@]} ; i ++)); do
${duser} ${DEL_CONSOLE_CMD} rm ${RM_DATA} ${ID[$i]}
done
else
printf " is no valid choice\n"
fi
fi
}
deluge_rm() {
names=($(${duser} ${DEL_CONSOLE_CMD} info | grep 'Name: ' | sed 's/ */_/g' | sed 's/Name: //g'))
if [ ${#names[@]} -eq 0 ]; then
stars
print_string "No Torrents in deluged client"
stars
exit 0;
fi
ID=($(${duser} ${DEL_CONSOLE_CMD} info | grep 'ID: ' | sed 's/ID: //g'))
printf "Which Torrent shall we eliminate?(Enter leading number)\n"
for ((i = 0 ; i < ${#names[@]} ; i ++)); do
printf "%s: %s\n" "$i" "${names[$i]}"
done
read -t 20 choice1
IFS=$';'; set -f
array=(${choice1})
unset IFS; set +f
for title in ${array[@]}; do
if [ ${title} -le ${#names[@]} 2>/dev/null ]; then
printf "Remove Torrent %d: %s\n" "${title}" "${names[${title}]}"
printf "Remove Data too?(y/q/*)(q for quit)\n"
read -t 10 -n 2 choice2
if [ "$choice2" == "y" ]; then
RM_DATA="--remove_data"
elif [ "$choice2" == "q" ]; then
echo "Cancel Removal"
return
else
RM_DATA=""
fi
${duser} ${DEL_CONSOLE_CMD} rm ${RM_DATA} ${ID[$title]}
if [ $(${duser} ${DEL_CONSOLE_CMD} info | grep -c "Name: ") -eq $((${#names[@]} - 1)) ]; then
printf "\e[32mDeletion Successfull\e[0m\n"
fi
elif [ "${choice1}" == "ALL" ]; then
printf "Remove Data too?(y/*)\n"
read -t 10 -n 2 choice2
if [ "$choice2" == "y" ]; then
RM_DATA="--remove_data"
else
RM_DATA=""
fi
for ((i = 0 ; i < ${#names[@]} ; i ++)); do
${duser} ${DEL_CONSOLE_CMD} rm ${RM_DATA} ${ID[$i]}
done
else
printf " is no valid choice\n"
fi
done
}
get_config "$@"
printf "Custom Deluged Torrent Client Starting\n"
if ${HANDY_MODE}; then
handy_deluge
elif ${RM_MODE}; then
deluge_rm
elif ${RMS_MODE}; then
deluge_rms "${RMS_SEARCH}"
elif ${NAMES_MODE}; then
printf "%s\n" "$(${duser} ${DEL_CONSOLE_CMD} info | grep 'Name:\|ID:')"
elif [[ "${SLIM_MODE}" == true ]] || [[ "${NORMAL_MODE}" == true ]] ||[[ "${SEARCH_MODE}" == true ]] ||[[ "${DETAIL_MODE}" == true ]]; then
while [ "${cond}" == "" ]; do
if [[ "${SLIM_MODE}" == true ]]; then
STRING=$(slim_deluge)
elif [[ "${NORMAL_MODE}" == true ]]; then
STRING=$(normal_deluge)
elif [[ "${SEARCH_MODE}" == true ]]; then
STRING=$(search_deluge)
elif [[ "${DETAIL_MODE}" == true ]]; then
STRING=$(detail_deluge)
fi
${duser} find /home/deluge-user/Downloads/Torrents/ -type f -name *".torrent" | while read line
do
${duser} mv "$line" "$(echo $line | sed 's/ /_/g')"
done
${duser} find /home/deluge-user/Downloads/Torrents/ -type f -name *".torrent" -exec ${DEL_CONSOLE_CMD} add "{}" \;
${duser} find /home/deluge-user/Downloads/Torrents/ -type f -name *".torrent" -exec rm {} \;
read -t 1 cond
if [[ ${cond} =~ .*magnet.* ]]; then
${duser} ${DEL_CONSOLE_CMD} add "${cond}"
cond=""
elif [[ ${cond} =~ .*torrent.* ]]; then
${duser} ${DEL_CONSOLE_CMD} add "/home/deluge-user/Downloads/Torrents/${cond}"
cond=""
elif [ "${cond:0:4}" == "-rms" ]; then
deluge_rms
cond=""
elif [ "${cond:0:3}" == "-rm" ]; then
deluge_rm
cond=""
elif [ "${cond:0:5}" == "-slim" ]; then
SLIM_MODE=true
NORMAL_MODE=false; SEARCH_MODE=false; DETAIL_MODE=false;
cond=""
elif [ "${cond:0:5}" == "-norm" ]; then
NORMAL_MODE=true
SLIM_MODE=false; SEARCH_MODE=false; DETAIL_MODE=false;
cond=""
elif [ "${cond:0:3}" == "-ON" ]; then
DOWNLOADING="Down Speed: 0.0 KiB/s"
cond=""
elif [ "${cond:0:4}" == "-OFF" ]; then
DOWNLOADING="ADCFEGCLG"
cond=""
elif [ "${cond:0:3}" == "-on" ]; then
DOWN="Speed"
cond=""
elif [ "${cond:0:4}" == "-off" ]; then
DOWN=""
cond=""
elif [ "${cond:0:2}" == "-c" ]; then
echo ${cond:3:$((${#cond}-3))}
sleep 2
${duser} ${DEL_CONSOLE_CMD} ${cond:3:$((${#cond}-3))}
cond=""
fi
sleep ${SLEEP_TIME}
clear
if [ "${STRING}" != "" ]; then
stars
print_string "Custom Deluge Client"
stars
echo -e "${STRING}"
else
stars
print_string "No Torrents in deluged client"
stars
fi
if ${STATIC_MODE}; then break; fi
done
else
usage
fi
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
sudo -u deluge-user -i -- "$@"
+1
View File
@@ -0,0 +1 @@
while true; do B=$(du -d1 /backup/DataRescue/ | tail -n1 | cut -f1); F=$(du -d1 /media/lucas/LucasFestplatte/ | tail -n1 | cut -f1); sleep 2; clear; echo "print ${F} / ${B} * 100" | perl; done
+7
View File
@@ -0,0 +1,7 @@
#!/bin/bash
echo "no" > /home/lucas/.auto_shutdown
if [[ "$(cat /home/lucas/.auto_shutdown)" == "no" ]]; then
echo "Auto shutdown DISABLED"
notify-send "Auto shutdown DISABLED"
fi
+6
View File
@@ -0,0 +1,6 @@
#!/bin/bash
echo "yes" > /home/lucas/.auto_shutdown
if [[ "$(cat /home/lucas/.auto_shutdown)" == "yes" ]]; then
echo "Auto shutdown ENABLED"
notify-send "Auto shutdown ENABLED"
fi
+5
View File
@@ -0,0 +1,5 @@
#!/bin/bash
if [[ "$@" == "" ]]; then
exit
fi
sudo -u lucas -i -- "$@" >> /home/lucas/lucas_cmd_log.txt
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
cp doc /media/lucas/Data/Backups/backup_$(date -d "today" +"%m%d")
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
>/home/lucas/arduinoOut.txt
while true # loop forever
do
date >> /home/lucas/arduinoOut.txt
data=$(cat /dev/ttyACM0 | head -n 20 | tail -n 20)
printf "$data" >> /home/lucas/arduinoOut.txt
#printf "$(date)\n$data\n"
done
+40
View File
@@ -0,0 +1,40 @@
#!/bin/bash
cond=true
while [ $cond == true ]; do
if [ "$(ls /torrent)" == "" ]; then
printf "No Torrents Found\n"
break
fi
printf "Torrents:\n"
ls /torrent/Complete/
printf "Remove all these Files?\n"
read ans
if [ "$ans" == "y" ]; then
printf "Torrents Removed\n"
cond=false
rm -dr /torrent/Complete/*
elif [ "$ans" == "n" ]; then
printf "Nothing Removed\n"
cond=false
elif [ "$ans" == "s" ]; then
printf "Remove Single Torrent or Group\n"
read group
if [ "$(ls /torrent/Complete/$group*)" == "" ]; then
printf "Nothing Found\n"
sleep 1
else
ls /torrent/Complete/$group*
printf "Remove?\n"
read ans
if [ "$ans" == "y" ]; then
rm -dr /torrent/complete/$group*
cond=false
printf "Torrents Removed\n"
elif [ "$ans" == "n" ]; then
printf "Nothing Removed\n"
cond=false
fi
fi
fi
done
+41
View File
@@ -0,0 +1,41 @@
#!/bin/bash
PW=$(cat /home/lucas/.PW)
FOLDER=/torrent/Memes
nextcloudcmd --trust --user lucas --password ${PW} --path Media/Stuff/Memes ${FOLDER} https://someoneslinux.ddns.net 1>/dev/null 2>&1
for IMG_ORIG in ${FOLDER}/*; do
if [[ "$(echo ${IMG_ORIG##*/} | grep "-")" != "" ]] || [[ "$(echo ${IMG_ORIG##*/} | grep " ")" != "" ]] ;then
mv "${IMG_ORIG}" "$(echo ${IMG_ORIG} | sed 's/-/_/g' | sed 's/ /_/g')"
IMG_ORIG="$(echo ${IMG_ORIG} | sed 's/-/_/g' | sed 's/ /_/g')"
fi
if [[ -f ${IMG_ORIG} ]] ; then
IMG_EXT=${IMG_ORIG##*/}
IMG=${IMG_EXT%%.*}
EXT=${IMG_ORIG##*.}
DIR=${IMG_ORIG%/*}
if [ "$(echo ${IMG} | grep "MEMES")" == "" ]; then
LAST_IDX=$(ls ${FOLDER}/MEMES* | rev | cut -f1 -d'/' | rev | cut -f1 -d'.' | sort | tail -1 | sed 's/MEMES//g')
NEW_IDX=$(echo "${LAST_IDX}+1" | bc)
mv ${IMG_ORIG} "$(printf "%s/MEMES%04d.%s" ${DIR} ${NEW_IDX} ${EXT})"
IMG_ORIG="$(printf "%s/MEMES%04d.%s" ${DIR} ${NEW_IDX} ${EXT})"
IMG_EXT=${IMG_ORIG##*/}
IMG=${IMG_EXT%%.*}
EXT=${IMG_ORIG##*.}
fi
if [ "$(echo ${EXT} | grep "webp")" != "" ]; then
echo Pic: $IMG
convert ${IMG_ORIG} $(echo ${IMG_ORIG} | sed 's/webp/jpg/g')
rm ${IMG_ORIG}
elif [ "$(echo ${EXT} | grep "png")" != "" ]; then
echo Pic: $IMG
convert ${IMG_ORIG} $(echo ${IMG_ORIG} | sed 's/png/jpg/g')
rm ${IMG_ORIG}
elif [ "$(echo ${EXT} | grep "webm")" != "" ]; then
echo Vid: $IMG
ffmpeg -y -i ${IMG_ORIG} $(echo ${IMG_ORIG} | sed 's/webm/mp4/g')
rm ${IMG_ORIG}
fi
fi
done
nextcloudcmd --trust --user lucas --password ${PW} --path Media/Stuff/Memes ${FOLDER} https://someoneslinux.ddns.net 1>/dev/null 2>&1
echo Fin
+238
View File
@@ -0,0 +1,238 @@
import os
import re
import random
import datetime
import sys
from PIL import Image, ExifTags
import subprocess
import json
from serverLibary import safe_rename
# Folder to scan
folder_path = '.'
# Supported image and video extensions
video_extensions = {
'.mp4', '.mov', '.avi', '.mkv', '.hevc'
}
img_extensions = {
'.jpg', '.jpeg', '.png', '.heic', '.webp',
}
extensions = img_extensions | video_extensions
prefixes = { 'IMG', 'VID'}
# Build reusable groups for regex
ext_group = r'(jpg|jpeg|png|heic|webp|mp4|mov|avi|mkv|hevc)'
prefix_group = r'(?:IMG|VID)'
# Correct format to keep
correct_format_re = re.compile(
rf'^{prefix_group}_(\d{{8}}_\d{{6}}).*\.{ext_group}$',
re.IGNORECASE
)
# Alternate timestamp formats and their patterns
alt_patterns = [
# PREFIX_YYYY_MM_DD_HH_MM_SS.ext
(
re.compile(
rf'^(?:{prefix_group}_)?(\d{{4}})_(\d{{2}})_(\d{{2}})_(\d{{2}})_(\d{{2}})_(\d{{2}}).*\.{ext_group}$',
re.IGNORECASE
),
'%Y_%m_%d_%H_%M_%S'
),
# PREFIX_YYYYMMDD_HHMMSS.ext
(
re.compile(
rf'^(?:{prefix_group}_)?(\d{{8}})_(\d{{6}}).*\.{ext_group}$',
re.IGNORECASE
),
'%Y%m%d_%H%M%S'
),
# PREFIX_YYYY.MM.DD-HHMMSS.ext
(
re.compile(
rf'^(?:{prefix_group}_)?(\d{{4}})\.(\d{{2}})\.(\d{{2}})-(\d{{6}}).*\.{ext_group}$',
re.IGNORECASE
),
'%Y.%m.%d-%H%M%S'
),
# PREFIX_YYYYMMDD.ext
(
re.compile(
rf'^(?:{prefix_group}_)?(\d{{8}})\.{ext_group}$',
re.IGNORECASE
),
'%Y%m%d'
),
# PREFIX_HHMMSS.ext
(
re.compile(
rf'^(?:{prefix_group}_)?(\d{{6}})\.{ext_group}$',
re.IGNORECASE
),
'%H%M%S'
),
]
# EXIF tag name for datetime
EXIF_DATE_TAGS = ['DateTimeOriginal', 'DateTimeDigitized', 'DateTime']
def local_safe_rename(src_path, new_filename):
"""Rename file safely, avoiding overwrites"""
directory = os.path.dirname(src_path)
base, ext = os.path.splitext(new_filename)
counter = 1
final_name = new_filename
while os.path.exists(os.path.join(directory, final_name)):
final_name = f"{base}_{counter}{ext}"
counter += 1
os.rename(src_path, os.path.join(directory, final_name))
print(f"Renamed: {os.path.basename(src_path)} ➜ {final_name}")
def get_exif_creation_datetime(filepath):
"""Try to extract creation datetime from image EXIF metadata"""
try:
with Image.open(filepath) as img:
exif = img._getexif()
if not exif:
return None
# Map tag ids to tag names
tag_label = {ExifTags.TAGS.get(k): v for k, v in exif.items() if k in ExifTags.TAGS}
for tag in EXIF_DATE_TAGS:
if tag in tag_label:
# EXIF date format: 'YYYY:MM:DD HH:MM:SS'
return datetime.datetime.strptime(tag_label[tag], '%Y:%m:%d %H:%M:%S')
except Exception as e:
pass
return None
def get_manufacturer(file_path):
# Call exiftool and get JSON output
result = subprocess.run(
["exiftool", "-j", file_path], # -j outputs JSON
capture_output=True,
text=True
)
# Parse JSON output
metadata = json.loads(result.stdout)[0]
# Extract Author tag and remove spaces
author = metadata.get("Author", "")
if author == "":
author = metadata.get("AndroidManufacturer", "")
author_no_spaces = author.replace(" ", "")
return author_no_spaces
def process_images(folder):
for fname in os.listdir(folder):
fpath = os.path.join(folder, fname)
if not os.path.isfile(fpath):
continue
_, ext = os.path.splitext(fname)
ext = ext.lower()
if ext not in extensions:
continue
# Step 1: Normalize filename by replacing '-' with '_'
normalized_name = fname.replace('-', '_')
if normalized_name != fname:
# Rename the file to the normalized name before continuing
new_path = os.path.join(folder, normalized_name)
safe_rename(fpath, new_path)
print(f"Normalized: {fname} ➜ {os.path.basename(new_path)}")
# Update fname and fpath to the new normalized filename
fname = os.path.basename(new_path)
fpath = new_path
videoManufacturer = ""
file_prefix = "IMG"
for extention in video_extensions:
if extention in ext:
file_prefix = "VID"
videoManufacturer = "_" + get_manufacturer(fpath)
for extention in img_extensions:
if extention in ext:
file_prefix = "IMG"
# Now continue with your existing logic on normalized fname
if correct_format_re.match(fname):
if videoManufacturer != "" and file_prefix == "VID":
if videoManufacturer in fname:
pass
else:
basename, _ = os.path.splitext(fname)
new_fname = f"{basename}{videoManufacturer}{ext}"
safe_rename(fpath, os.path.join(folder, new_fname))
continue
print(f"[OK] {fname} already correctly named.")
continue
matched = False
for pattern, fmt in alt_patterns:
m = pattern.match(normalized_name)
if m:
try:
parts = m.groups()
timestamp_str = '_'.join(parts[:2]) if len(parts) >= 2 else parts[0]
dt = datetime.datetime.strptime(timestamp_str, fmt)
new_fname = f"{file_prefix}_{dt.strftime('%Y%m%d_%H%M%S')}{videoManufacturer}{ext}"
safe_rename(fpath, os.path.join(folder, new_fname))
matched = True
break
except Exception as e:
continue
if matched:
continue
# 3. Try reading creation date from metadata
dt = get_exif_creation_datetime(fpath)
if dt:
new_fname = f"{file_prefix}_{dt.strftime('%Y%m%d_%H%M%S')}{videoManufacturer}{ext}"
safe_rename(fpath, new_fname)
continue
# 4. Fallback: keep original name, add _RX_<random> (only if not already added)
if '_RX_' in fname:
print(f"[SKIP] {fname} already has fallback name.")
continue
basename, _ = os.path.splitext(fname)
rand_num = random.randint(100000, 999999)
new_fname = f"{basename}_RX_{rand_num}{videoManufacturer}{ext}"
safe_rename(fpath, new_fname)
# ---- Main script entry ----
if __name__ == '__main__':
if len(sys.argv) < 2:
print("Usage: python script.py <image_folder_path>")
sys.exit(1)
folder_path = sys.argv[1]
if not os.path.isdir(folder_path):
print(f"Error: '{folder_path}' is not a valid directory.")
sys.exit(1)
print(f"Processing images in: {os.path.abspath(folder_path)}\n")
process_images(folder_path)
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
PW=$(cat /home/lucas/.PW)
FOLDER=/torrent/Camera
SERVER="https://someoneslinux.ddns.net"
nextcloudcmd --trust --user lucas --password ${PW} --path Media/Pictures/Camera ${FOLDER} ${SERVER} 1>/dev/null 2>&
/home/lucas/.venv_general/bin/python3 /home/lucas/scripts/serverhost/rename_camera_folder.py ${FOLDER}
nextcloudcmd --trust --user lucas --password ${PW} --path Media/Pictures/Camera ${FOLDER} ${SERVER} 1>/dev/null 2>&1
+58
View File
@@ -0,0 +1,58 @@
#!/bin/bash
PW=$(cat /home/lucas/.PW)
FOLDER=/torrent/Camera
SERVER="https://someoneslinux.ddns.net"
nextcloudcmd --trust --user lucas --password ${PW} --path Media/Pictures/Camera ${FOLDER} ${SERVER} 1>/dev/null 2>&1
find ${FOLDER}/* -type f | xargs -0 -n 1 echo | while read IMG_ORIG
do
if [[ -d "${IMG_ORIG}" ]] | [[ ! -f "${IMG_ORIG}" ]]; then
echo "Item no File, (${IMG_ORIG})"
continue
fi
IMG=${IMG_ORIG}
IMG_PATH=${IMG%/*}
IMG_FILE=${IMG##*/}
PREFIX=${IMG_FILE:0:4}
if [[ "${PREFIX}" != "IMG_" ]] || [[ "${PREFIX}" != "VID_" ]]; then
if [ "$(echo ${IMG} | grep "mp4")" == "" ]; then
PREFIX="IMG_"
else
PREFIX="VID_"
fi
fi
if [[ "${IMG_FILE:0:4}" == "PANO" ]]; then
echo Pano
IMG="$(echo ${IMG} | sed 's/-//g')"
fi
if [[ "$(echo ${IMG##*/} | grep "-")" != "" ]];then
IMG="$(echo ${IMG} | sed 's/-/_/g')"
fi
NUM="$(echo ${IMG%.*} | grep -o -E "[0-9]+_[0-9]+")"
if [[ $(echo ${NUM} | wc -c) -gt 16 ]]; then
echo "Remove long num ${NUM}"
if [ "$(echo ${IMG} | grep "mp4")" == "" ]; then
PREFIX="IMG_"
else
PREFIX="VID_"
fi
NUM="${NUM:0:15}"
fi
if [[ "${IMG}" == *"_RX0"* ]]; then
echo "Randomized Img"
NUM="$(echo ${IMG%.*} | grep -o -E "[0-9]+_[0-9]+_RX0[0-9]+")"
fi
IMG_NEW=${IMG_PATH}/${PREFIX}${NUM}.${IMG##*.}
if [[ "${IMG_ORIG}" != "${IMG_NEW}" ]];then
if [[ -f "${IMG_NEW}" ]]; then
echo "Add Random"
IMG_NEW=${IMG_PATH}/${PREFIX}${NUM}_RX0${RANDOM}.${IMG##*.}
fi
mv "${IMG_ORIG}" "${IMG_NEW}"
echo "Rename ${IMG_ORIG} to ${IMG_NEW}"
# else
# echo "Equal Name ${IMG_NEW}"
fi
done
nextcloudcmd --trust --user lucas --password ${PW} --path Media/Pictures/Camera ${FOLDER} ${SERVER} 1>/dev/null 2>&1
+35
View File
@@ -0,0 +1,35 @@
#!/bin/bash
NC_PATH="/home/lucas/Documents/Dokumente/Projekte/Server"
printf "\e[34mSync Nextcloud\e[0m\n"
syncNC > /dev/null 2>&1
printf "\n\e[34mquiethost\e[0m\n"
ssh quiethost "crontab -l > /home/lucas/Documents/Dokumente/Projekte/Server/crontab.quiethost.lucas"
scp lucas@quiethost:/etc/sudoers.d/nopasswdcmds $NC_PATH/nopasswdcmds.quiethost
scp lucas@quiethost:/etc/systemd/system/vpn.service $NC_PATH/vpn.service.quiethost
scp lucas@quiethost:/etc/systemd/system/WallpaperChanger.service $NC_PATH/quiethost/WallpaperChanger.service.quiethost
scp lucas@quiethost:.config/Nextcloud/nextcloud.cfg $NC_PATH/quiethost/Nextcloud/
scp lucas@quiethost:.config/Nextcloud/sync-exclude.lst $NC_PATH/quiethost/Nextcloud/
scp lucas@quiethost:.local/share/applications/*.desktop $NC_PATH/quiethost/
scp lucas@quiethost:.config/autostart/*.desktop $NC_PATH/quiethost/autostart/
if [ "$1" == "-win" ]; then
ssh quiethost pkill firefox
scp lucas@quiethost:/win10/Users/lucas/AppData/Roaming/Mozilla/Firefox/Profiles/*.default/places.sqlite $NC_PATH/quiethost/
scp $NC_PATH/quiethost/places.sqlite lucas@quiethost:.mozilla/firefox/*.default-release/places.sqlite
else
scp lucas@quiethost:.mozilla/firefox/*.default-release/places.sqlite $NC_PATH/quiethost/
scp $NC_PATH/quiethost/places.sqlite lucas@quiethost:/win10/Users/lucas/AppData/Roaming/Mozilla/Firefox/Profiles/*.default/
fi
scp lucas@quiethost:.unison/*.prf $NC_PATH/quiethost/Unison/
ssh quiethost cp /home/lucas/.config/quodlibet/playlists/* /data/DatenLucas/Music/Playlists/
printf "\e[34mServerhost\e[0m\n"
cp /etc/sudoers.d/nopasswdcmds $NC_PATH/nopasswdcmds.serverhost
#cp /etc/rc.local $NC_PATH/rc.local.serverhost
printf "\e[34mRaspberry\e[0m\n"
rsync -rthvue "ssh -p 1160" --delete-delay --progress lucas@raspberry:/home/lucas/Raspberry/ $NC_PATH/Raspberry/
scp lucas@raspberry:/etc/sudoers.d/nopasswdcmds $NC_PATH/nopasswdcmds.raspberry
scp lucas@raspberry:/etc/rc.local $NC_PATH/rc.local.raspberry
printf "\e[34mRaspberry CRON\e[0m\n"
/usr/bin/expect /home/lucas/Documents/Dokumente/Projekte/Server/scripts/cron.sh
printf "\e[34mSync Nextcloud\e[0m\n"
syncNC > /dev/null 2>&1
printf "\e[34mScriptcopy Finished!\e[0m\n"
+27
View File
@@ -0,0 +1,27 @@
#!/bin/bash
echo "Check for Serverhost state"
SHUTDOWN=true
if [ $(cat /home/lucas/.auto_shutdown | grep yes | wc -l) -lt 1 ] ; then
echo "Auto Shutdown disabled"
SHUTDOWN=false
fi
if [ $(ps -elf | grep -e 'backup_all\.sh' | grep -v grep | wc -l) -ge 1 ]; then
echo "Backup in progress"
SHUTDOWN=false
fi
if [ $(ps -elf | grep -e 'upgrade\.sh' | grep -v grep | wc -l) -ge 1 ]; then
echo "Upgrade in progress"
SHUTDOWN=false
fi
if $SHUTDOWN; then
echo "Shutdown serverhost"
sudo /sbin/shutdown -P 1 +6
ssh -o ConnectTimeout=4 -p 1504 lucas@quiethost 'notify-send "Shutdown SUCCESSFUL for Serverhost"'
timeout 2s notify-send "Shutdown SUCESSFULL for Serverhost"
else
echo "Skip shutdown"
ssh -o ConnectTimeout=4 -p 1504 lucas@quiethost 'notify-send "Shutdown FAILED for Serverhost"'
timeout 2s notify-send "Shutdown FAILED for Serverhost"
fi
+14
View File
@@ -0,0 +1,14 @@
#!/bin/bash
count=0
DISKS=($(lsblk | grep disk | cut -f1 -d' '))
for disk in ${DISKS[@]}; do
echo "Test disk ${disk}" > /tmp/log_${disk}
{ sudo smartctl -H /dev/${disk} >> /tmp/log_${disk}; echo "Result: $?" >> /tmp/log_${disk};}& PID[$count]=$!
((count++))
done
MAIL_BODY=""
for (( i=0; i<${#PID[@]};i++)); do
wait ${PID[$i]}
MAIL_BODY="$(printf "${MAIL_BODY}\n$(cat /tmp/log_${DISKS[$i]})\nsmartctl for disk ${DISKS[$i]} finished")"
done
echo "${MAIL_BODY}" | mail -s "Automated Servermessage - smartctl" lucas-f@live.at
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
#!/bin/bash
count=0
DISKS=($(lsblk | grep disk | cut -f1 -d' '))
for disk in ${DISKS[@]}; do
echo "Test disk ${disk}" > /tmp/log_${disk}
{ sudo smartctl -H /dev/${disk} >> /tmp/log_${disk}; echo "Result: $?" >> /tmp/log_${disk};}& PID1[$count]=$!
{ sudo smartctl -t long /dev/${disk} >> /tmp/log_${disk}; echo "Result: $?" >> /tmp/log_${disk};}& PID2[$count]=$!
((count++))
done
MAIL_BODY=""
STARS="***************************"
for (( i=0; i<${#PID1[@]};i++)); do
wait ${PID1[$i]}
wait ${PID2[$i]}
MAIL_BODY="$(printf "${STARTS}${DISKS[$i]}${STARTS}${MAIL_BODY}\n$(cat /tmp/log_${DISKS[$i]})\nsmartctl for disk ${DISKS[$i]} finished")"
done
echo "${MAIL_BODY}" | mail -s "Automated Servermessage - smartctl long" lucas-f@live.at
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
#!/bin/bash
count=0
DISKS=($(lsblk | grep disk | cut -f1 -d' '))
for disk in ${DISKS[@]}; do
echo "Test disk ${disk}" > /tmp/log_${disk}
{ sudo smartctl -a /dev/${disk} >> /tmp/log_${disk}; echo "Result: $?" >> /tmp/log_${disk};}& PID1[$count]=$!
((count++))
done
MAIL_BODY=""
for (( i=0; i<${#PID1[@]};i++)); do
wait ${PID[$i]}
MAIL_BODY="$(printf "%s\n%s\nsmartctl for disk %s finished" "${MAIL_BODY}" "$(cat /tmp/log_${DISKS[$i]})" "${DISKS[$i]}")"
done
echo "${MAIL_BODY}" | mail -s "Automated Servermessage - smartctl long result" lucas-f@live.at
+105
View File
@@ -0,0 +1,105 @@
#!/bin/bash
ret=0
count=20
PW=$(cat /home/lucas/.PW)
SYNC_MEDIA=0
SYNC_RECIPIES=1
SYNC_MEDIA_ONLY=0
SYNC_THEMES=0
SILENT=true
SERVER="https://someoneslinux.ddns.net"
while [[ ${1:0:1} == - ]]; do
echo "Param: $1"
[[ $1 == -l ]] && {
SILENT=false;
shift 1;
continue;
};
[[ $1 == -o ]] && {
SYNC_MEDIA_ONLY=1;
shift 1;
continue;
};
[[ $1 == -m ]] && {
SYNC_MEDIA=1;
shift 1;
continue;
};
[[ $1 == -t ]] && {
SYNC_THEMES=1;
shift 1;
continue;
};
[[ $1 == -del ]] && {
if [ -f /tmp/nextcloud_sync ]; then
rm /tmp/nextcloud_sync
echo "File removed"
fi
shift 1;
continue;
};
echo "Parameter $1 discarded"
shift 1;
done
if $SILENT; then
target='>/dev/null 2>&1'
fi
if [ ! -f /tmp/nextcloud_sync ]; then
touch /tmp/nextcloud_sync
echo "Sync Nextcloud"
while true; do
ret=0
if [ ${SYNC_MEDIA} -eq 1 ];then
echo "Sync Multmedia"
sudo /home/lucas/scripts/serverhost/tvbitch_user_cmd.sh nextcloudcmd --trust --user multimedia --password multimedia123 --path Filme/New /torrent/multimedia/Filme/New ${SERVER} >/dev/null 2>&1
ret=$(( ret + $? ))
#echo Return: $ret
fi
if [[ ${SYNC_THEMES} -eq 1 ]] && [[ ${SYNC_MEDIA_ONLY} -eq 0 ]]; then
echo "Sync Themes"
nextcloudcmd --trust --user lucas --password ${PW} --path Dokumente/Dokumente/Projekte/Handy/ThemeProject/SolarSystemTheme /home/lucas/Documents/Dokumente/Projekte/Handy/ThemeProject/SolarSystemTheme ${SERVER} >/dev/null 2>&1
ret=$(( ret + $? ))
#echo Return: $ret
fi
if [[ ${SYNC_RECIPIES} -eq 0 ]];then
echo "Sync Recipies"
nextcloudcmd --trust --user lucas --password ${PW} --path Dokumente/Dokumente/Shared/Diverses/Kochbuch/RecepiesLucas /home/lucas/Documents/Dokumente/Shared/Diverses/Kochbuch/RecepiesLucas ${SERVER} >/dev/null 2>&1
ret=$(( ret + $? ))
#echo Return: $ret
fi
if [[ "$1" != "-W" ]] && [[ ${SYNC_MEDIA_ONLY} -eq 0 ]];then
echo "Sync Server"
# echo "nextcloudcmd --trust --user lucas --password ${PW} --path Dokumente/Dokumente/Projekte/Server /home/lucas/Documents/Dokumente/Projekte/Server ${SERVER}" #>/dev/null 2>&1
nextcloudcmd --trust --user lucas --password ${PW} --path Dokumente/Dokumente/Projekte/Server /home/lucas/Documents/Dokumente/Projekte/Server ${SERVER} >/dev/null 2>&1
ret=$(( ret + $? ))
#echo Return: $ret
fi
if [[ ${SYNC_MEDIA_ONLY} -eq 0 ]]; then
echo "Sync Wallpaper"
nextcloudcmd --trust --user lucas --password ${PW} --path Media/Stuff/Wallpaper /torrent/WallpaperChanger ${SERVER} >/dev/null 2>&1
ret=$(( ret + $? ))
#echo Return: $ret
fi
if [[ "${ret}" == "0" ]]; then
echo "Sucess"
if [ -f /tmp/nextcloud_sync ]; then
rm /tmp/nextcloud_sync
fi
break
elif [[ ${count} -gt 15 ]]; then
echo "Massive Fail"
if [ -f /tmp/nextcloud_sync ]; then
rm /tmp/nextcloud_sync
fi
break
else
echo "Fail"
sleep 5
fi
((count++))
done
else
echo "Nextcloud Sync active, stop"
fi
exit ${ret}
+227
View File
@@ -0,0 +1,227 @@
#!/bin/bash
CUR_DIR=$(pwd)
THEMES_PROJECT_FOLDER="/home/lucas/Documents/Dokumente/Projekte/Handy/ThemeProject"
UNZIP=false
BUILD=false
FIND=false
FONT="DroidSans"
BUILD_NC_THEME=false
THEME_NAME="SolarSystemTheme"
usage() {
printf "Usage:
-build\t\tBuild the Theme
-build_NC\t\tBuild the NextCloud Theme
-unzip\t\tUnzip com.* folders in the Theme Project Folder
-name <name>\tAlternate Theme Name(Default: SolarSystemTheme)
-font <name>
-f <arg>\tFind arg in Theme Files
-p <path>\tPath of the Theme Project Folder(default: quiethost path)
-h\t\tDisplay Usage
-help\tDisplay Usage\n"
}
get_config() {
while [[ ${1:0:1} == - ]]; do
echo "Param: $1"
[[ $1 == -build ]] && {
BUILD=true
shift 1;
continue;
};
[[ $1 == -build_NC ]] && {
BUILD_NC_THEME=true
shift 1;
continue;
};
[[ $1 == -name ]] && {
if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi
THEME_NAME="$2"
shift 2;
continue;
};
[[ $1 == -font ]] && {
FIND=true
if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi
FONT="$(echo $2 | sed 's/.ttf//g')"
shift 2;
continue;
};
[[ $1 == -f ]] && {
FIND=true
if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi
FIND_arg="$2"
shift 2;
continue;
};
[[ $1 == -p ]] && {
if [ "$2" == "" ]; then
printf "Too few arguments\nPath: ${THEMES_PROJECT_FOLDER}\n"
shift 1
continue
fi
THEMES_PROJECT_FOLDER="$2"
shift 2;
continue;
};
[[ $1 == -unzip ]] && {
UNZIP=true
shift 1;
continue;
};
[[ $1 == -help ]] && {
usage
exit
};
echo "Parameter $1 discarded"
usage
shift 1;
done
}
build_theme() {
date=$(date +"%m%d%H%M%S")
if [ -d ".${THEME_NAME}_BUFF" ]; then
rm -dr .${THEME_NAME}_BUFF
fi
mkdir .${THEME_NAME}_BUFF
echo "${CUR_DIR}"
echo "Contacts Background"
ICON_str="${THEME_NAME}/ContactsBG/ContactsBG"
if [ -d "${THEME_NAME}/ContactsBG" ]; then
if [ "$(ls ${ICON_str}*png)" != "" ]; then
echo "Choose random Contacts Background"
RAND_NUM=$(($RANDOM % $(ls ${THEME_NAME}/ContactsBG/*png | wc -l) + 1 ))
echo "${ICON_str}${RAND_NUM}.png"
cp ${ICON_str}${RAND_NUM}.png ${THEME_NAME}/com.android.contacts/res/drawable-xxhdpi/contact_detail_list_background.9.png
cp ${ICON_str}${RAND_NUM}.png ${THEME_NAME}/framework-res-hwext/res/drawable-xxhdpi/background_emui.9.png
fi
fi
for folder in $(ls -d ${THEME_NAME}/com.*); do
folder="$(echo "${folder}" | rev | cut -f1 -d'/' | rev)"
echo ${folder}
if [ -d ".${THEME_NAME}_BUFF/${folder}" ]; then
rm -dr .${THEME_NAME}_BUFF/${folder}
fi
cp -r ${THEME_NAME}/framework-res-hwext ${THEME_NAME}/${folder}
cd ${THEME_NAME}/${folder}
zip -q -r ${folder} *
mv ${folder} ../../.${THEME_NAME}_BUFF/${folder}
cd ${THEMES_PROJECT_FOLDER}
rm -dr ${THEME_NAME}/${folder}/framework-res-hwext
done
if [ -f ".${THEME_NAME}_BUFF/icons" ]; then
rm .${THEME_NAME}_BUFF/icons
fi
echo "Icons"
ICON=("Toshl" "FoE" "Hangar")
HUAWEI_name=("com.thirdframestudios.android.expensoor.png" "com.innogames.foeandroid.png" "me.calebjones.spacelaunchnow.png")
for (( i=0 ; i<${#ICON[@]} ; i++ )); do
ICON_str="${THEME_NAME}/${ICON[$i]}/${ICON[$i]}"
if [ -d "${THEME_NAME}/${ICON[$i]}" ]; then
if [ "$(ls ${ICON_str}*png)" != "" ]; then
echo "Choose random ${ICON[$i]} Icon"
cp ${ICON_str}$(($RANDOM % $(ls ${ICON_str}*png | wc -l) + 1 )).png ${THEME_NAME}/icons/${HUAWEI_name[$i]}
fi
fi
done
cd ${THEME_NAME}/icons
zip -q -r icons.zip *
mv icons.zip ../../.${THEME_NAME}_BUFF/icons
cd ${THEMES_PROJECT_FOLDER}
if [ -f "${THEME_NAME}.zip" ]; then
rm ${THEME_NAME}.zip
fi
echo "Preview, Unlock, Wallpaper, font and description.xml"
if [ -f "${THEME_NAME}/fonts/${FONT}.ttf" ]; then
echo "Use font ${FONT}"
mkdir .${THEME_NAME}_BUFF/fonts
cp ${THEME_NAME}/fonts/${FONT}.ttf .${THEME_NAME}_BUFF/fonts/${FONT}Chinese.ttf
else
echo "Font ${RONT} not available"
fi
cp -r ${THEME_NAME}/preview .${THEME_NAME}_BUFF/
cp -r ${THEME_NAME}/unlock .${THEME_NAME}_BUFF/
cp -r ${THEME_NAME}/wallpaper .${THEME_NAME}_BUFF/
cp -r ${THEME_NAME}/description.xml .${THEME_NAME}_BUFF/
cd .${THEME_NAME}_BUFF
echo "Create ${THEME_NAME}_${date}.hwt"
sed -i 's/Theme<\/title/Theme_'"${date}"'<\/title/g' description.xml
zip -q -r ${THEME_NAME}.zip *
cp ${THEME_NAME}.zip ../${THEME_NAME}_${date}.hwt
cd ${THEMES_PROJECT_FOLDER}
echo "Remove Smartphone themecache, .cache and old ${THEME_NAME}s"
if [ "$(find /run/user/$(id -u $(whoami))/gvfs/mtp:host*/Inter*/Huawei/Themes/ -name "${THEME_NAME}*")" != "" ]; then
rm /run/user/$(id -u $(whoami))/gvfs/mtp:host*/Inter*/Huawei/Themes/${THEME_NAME}*
fi
if [ -d /run/user/$(id -u $(whoami))/gvfs/mtp:host*/Inter*/Huawei/Themes/themecache ]; then
rm -dr /run/user/$(id -u $(whoami))/gvfs/mtp:host*/Inter*/Huawei/Themes/themecache
fi
if [ -d /run/user/$(id -u $(whoami))/gvfs/mtp:host*/Inter*/Huawei/Themes/.cache ]; then
rm -dr /run/user/$(id -u $(whoami))/gvfs/mtp:host*/Inter*/Huawei/Themes/.cache
fi
echo "Transfer Theme to Smartphone"
cp --no-preserve=ownership,timestamps ${THEME_NAME}_${date}.hwt /run/user/$(id -u $(whoami))/gvfs/mtp:host*/Inter*/Huawei/Themes/
echo "Move local Theme to NC"
cp ${THEME_NAME}_${date}.hwt ${THEME_NAME}/${THEME_NAME}.hwt
rm -dr .${THEME_NAME}_BUFF
}
unzip_com() {
CUR_DIR="$(pwd)"
rm -dr ${THEME_NAME}/*
unzip ${THEME_NAME}.hwt -d ${THEME_NAME}/
for folder in $(ls -d ${THEME_NAME}/com.*); do
folder="$(echo "${folder}" | rev | cut -f1 -d'/' | rev)"
echo ${folder}
if [ -d "${THEME_NAME}/${folder}" ]; then
echo "${folder} is a Directory"
exit
fi
if [ -d "${THEME_NAME}/buf_${folder}" ]; then
rm -dr buf_${folder}
fi
cd ${THEME_NAME}
unzip -q ${folder} -d buf_${folder}
rm ${folder}
if [ -d "buf_${folder}" ];then
mv buf_${folder} ${folder}
fi
if [ -d "${folder}/framework-res-hwext" ];then
cp -r ${folder}/framework-res-hwext framework-res-hwext_${folder}
rm -dr ${folder}/framework-res-hwext
fi
cd ${CUR_DIR}
done
unzip ${THEME_NAME}/icons -d ${THEME_NAME}/icons_buff
rm ${THEME_NAME}/icons
mv ${THEME_NAME}/icons_buff ${THEME_NAME}/icons
}
find_themes() {
grep "${FIND_arg}" -r ${THEME_NAME}/*
}
build_NC_theme() {
NC_THEME_DIR="/home/lucas/Documents/Dokumente/Projekte/Server/serverhost/NextCloudThemes/"
theme_NUM=2
rsync -rlvz --delete ${NC_THEME_DIR}${THEME_NAME}${theme_NUM}/* /nextcloud/nextcloud/themes/${THEME_NAME}/
sudo chown -R www-data /nextcloud/nextcloud/themes/${THEME_NAME}
sudo chgrp -R www-data /nextcloud/nextcloud/themes/${THEME_NAME}
}
sync_image() {
echo "Sync Nextcloud"
if [ $(id -u) -eq 0 ]; then
sudo -u lucas /usr/bin/syncNC -t > /dev/null 2>&1
else
/usr/bin/syncNC -t > /dev/null 2>&1
fi
}
if [ $# -lt 1 ]; then usage; fi
get_config "$@"
echo "Move to ${THEMES_PROJECT_FOLDER}"
sync_image
cd ${THEMES_PROJECT_FOLDER}
if ${BUILD}; then build_theme; fi
if ${UNZIP}; then unzip_com; fi
if ${FIND}; then find_themes; fi
if ${BUILD_NC_THEME}; then build_NC_theme; fi
cd ${CUR_DIR}
sync_image
+13
View File
@@ -0,0 +1,13 @@
#!/bin/bash
date="$(date +"%Y-%m-%d %T")"
#echo $date
/usr/bin/expect <<EOD
log_user 1
spawn ssh -p 1160 lucas@raspberry
expect "$ "
send "sudo date --set='$date'\r"
expect "$ "
send "exit\r"
expect "$ "
EOD
exit
+24
View File
@@ -0,0 +1,24 @@
#!/bin/bash
PW=$(cat /home/lucas/.PW)
FOLDER=/torrent/magnets/
nextcloudcmd --trust --user lucas --password ${PW} --path Dokumente/Dokumente/Shared/Magnets ${FOLDER} https://localhost 1>/dev/null 2>&1
filename="${FOLDER}Magnets.md"
while IFS= read -r line
do
sudo /home/lucas/scripts/serverhost/deluge_user_cmd.sh deluge-console "connect 127.0.0.1:58846; add ${line}" 1>/dev/null 2>&1
done < "${filename}"
> ${filename}
FILES="${FOLDER}*.torrent"
if [ -f ${FILES} ]; then
for file in $FILES
do
echo "Processing ${file} file..."
cat "${file}"
rm "${file}"
done
fi
nextcloudcmd --trust --user lucas --password ${PW} --path Dokumente/Dokumente/Shared/Magnets ${FOLDER} https://localhost 1>/dev/null 2>&1
+84
View File
@@ -0,0 +1,84 @@
import sys
import paho.mqtt.client as mqtt
import logging
# Set up logging configuration
log_file = '/home/lucas/logfile.log' # Replace with your desired log file location
logging.basicConfig(
filename=log_file, # Log file location
level=logging.DEBUG, # Log level: DEBUG, INFO, WARNING, ERROR, CRITICAL
format='%(asctime)s - %(levelname)s - %(message)s', # Log format
filemode='a' # 'a' to append logs, 'w' to overwrite logs each time
)
logging.info(f"Start")
# Define the MQTT broker connection details
MQTT_BROKER_HOST = "homeassistant"
MQTT_BROKER_PORT = 1883
MQTT_USERNAME = "MQTTBrokerUser"
MQTT_PASSWORD = "mqtt1510##"
MQTT_TOPIC = "serverhost_torrent_sensor/topic" # Set the desired topic
# Define the on_connect callback
def on_connect(client, userdata, flags, rc):
print(f"Connected with result code {rc}")
# Define callback functions
def on_connect(client, userdata, flags, rc):
"""Callback when the client connects to the broker."""
print(f"Connected with result code {rc}")
# Subscribe to a topic if needed
client.subscribe(MQTT_TOPIC)
def on_message(client, userdata, msg):
"""Callback when a message is received from the broker."""
print(f"Received message: {msg.payload.decode()} on topic: {msg.topic}")
def on_subscribe(client, userdata, mid, granted_qos):
"""Callback when a subscription is successful."""
print(f"Subscribed to topic with QoS {granted_qos}")
try:
# Your code that is causing the error
# Create an MQTT client instance
mqttc = mqtt.Client()
# Set username and password for authentication
mqttc.username_pw_set(username=MQTT_USERNAME, password=MQTT_PASSWORD)
# Connect to the MQTT broker
mqttc.connect(MQTT_BROKER_HOST, MQTT_BROKER_PORT, 60)
# Attach the callback functions
mqttc.on_connect = on_connect
mqttc.on_message = on_message
mqttc.on_subscribe = on_subscribe
# Start the MQTT client loop in the background
mqttc.loop_start()
# Prepare the message from command-line arguments
message = ' '.join(sys.argv[1:]) # Collect all arguments except the script name
logging.info(f"Message: {message}")
if message:
# Publish the message to the specified topic
mqttc.publish(MQTT_TOPIC, message)
print(f"Message sent: {message}")
else:
print("No message provided. Please provide some arguments to send.")
# Disconnect from the broker
mqttc.disconnect()
# Stop the MQTT client loop
mqttc.loop_stop()
pass
except AttributeError as e:
logging.error(f"Error: {e}")
+12
View File
@@ -0,0 +1,12 @@
#!/bin/bash
deluge-console "connect 127.0.0.1:58846; rm $1 -c" 2>/dev/null
echo "$@" >> /home/lucas/.LOG/log_torrentlog.txt
/home/lucas/mqqt_venv/bin/python /home/lucas/scripts/serverhost/torrent_mqtt.py "$*"
#sudo mail -s 'Torr Completed' lucas-f@live.at <<< "Finished at : $(date)"
#sudo /home/lucas/scripts/serverhost/lucas_cmd.sh ping -c 1 quiethost >> /dev/null
#if [ $? -eq 0 ]; then
# sudo /home/lucas/scripts/serverhost/lucas_cmd.sh ssh lucas@quiethost -p 1504 notify-send 'Torrent Complete'
#fi
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
chown -R lucas:lucas "$@"
+75
View File
@@ -0,0 +1,75 @@
#!/bin/bash
duser="sudo /home/lucas/scripts/deluge_user_cmd.sh"
FILE_PATH="/torrent/complete/"
STUFF="/home/lucas/Documents/Dokumente/Projekte/Server/Transfer/"
ASSUMEYES=false
usage() {
printf "Usage:
-y\ty Mode
-m\tMega Mode
-help\tDisplay this\n"
}
get_config() {
while [[ ${1:0:1} == - ]]; do
echo "Param: $1"
[[ $1 == -help ]] && {
echo "Help true"
usage;
exit;
};
[[ $1 == -y ]] && {
echo "y Mode"
ASSUMEYES=true
shift 1
continue
};
echo "Parameter $1 discarded"
usage
exit
done
}
get_config "$@"
syncNC
IFS=$'\n'; set -f
LIST=($(ls ${FILE_PATH}))
if [ ${#LIST[@]} -eq 0 ]; then
echo "Nothing to Copy/Delete"
exit
fi
if [ "${ASSUMEYES}" == "false" ]; then
echo "Copy? (y/*)"
echo "${LIST[@]}"
read -n 10 ans
else
ans="y"
fi
fail=false
if [ "$ans" == "y" ]; then
for files in ${LIST[@]}; do
cp -r ${FILE_PATH}${files} ${STUFF}
if [ $? -ne 0 ]; then fail=true; echo "Copy Failure"; exit; fi
chmod 777 -R ${STUFF}${files}
done
printf "Torrents Copied\n"
else
printf "Nothing Copied\n"
fi
if [ "${ASSUMEYES}" == "false" ]; then
echo "Delete? (y/*)"
echo "${LIST[*]}"
read -n 10 ans
else
ans="y"
fi
if [ "$ans" == "y" ]; then
for files in ${LIST[@]}; do
echo "Delete $files"
sudo /home/lucas/scripts/deluge_user_cmd.sh rm -dr ${FILE_PATH}${files}
done
printf "Torrents Removed\n"
else
printf "Nothing Removed\n"
fi
syncNC >> /dev/null 2>&1
+2
View File
@@ -0,0 +1,2 @@
#!/bin/bash
sudo -u tv-bitch -i -- "$@"
+113
View File
@@ -0,0 +1,113 @@
#!/bin/bash
SITES=("https://www.fondsprofessionell.at/fonds/details/fondsName/Amundi-Komfort-Invest-traditionell-T/ISIN/AT0000801071/fondsID/FU_80107/"
"https://www.fondsprofessionell.at/fonds/details/ISIN/AT0000A2L443/fondsID/FU_100076607/"
"https://www.fondsprofessionell.at/fonds/details/fondsName/Amundi-CPR-Climate-Action-T/ISIN/AT0000A28YU4/fondsID/FU_100070247/"
"https://www.finanzen.net/index/dow_jones" "https://www.finanzen.net/index/dax" "https://www.finanzen.net/index/atx")
if [ -f /home/lucas/Documents/Dokumente/Projekte/Server/www/BA_Data.html ]; then
BA_JS="/home/lucas/Documents/Dokumente/Projekte/Server/www/data.js"
BA_DATA="/home/lucas/Documents/Dokumente/Projekte/Server/www/BA_Data.html"
else
exit
fi
DEBUG=false
if [ "$1" == "-d" ];then
DEBUG=true
fi
DATE="$(date +"%d.%m.%Y")"
if [ $# -eq 3 ]; then
KURS_INET1="$1"
KURS_INET2="$2"
KURS_INET3="$3"
else
KURS_INET1=""
KURS_INET2=""
KURS_INET3=""
DOWJ=""
DAX=""
GET=true
if ${GET}; then
KURS_INET1=$(wget -qO- ${SITES[0]} | sed 's/<\//\n<\//g' | grep -A2 "NAV am" | grep -o -P '(?<=<td> ).*(?=EUR)' | sed 's/ //g' | sed 's/,/./g')
KURS_INET2=$(wget -qO- ${SITES[1]} | sed 's/<\//\n<\//g' | grep -A2 "NAV am" | grep -o -P '(?<=<td> ).*(?=EUR)' | sed 's/ //g' | sed 's/,/./g')
#KURS_INET2=$(wget -qO- ${SITES[1]} | grep "Rücknahmepreis" | grep -o -P '(?<=right">).*(?=</td>)' | sed 's/,/./g')
KURS_INET3=$(wget -qO- ${SITES[2]} | sed 's/<\//\n<\//g' | grep -A2 "NAV am" | grep -o -P '(?<=<td> ).*(?=EUR)' | sed 's/ //g' | sed 's/,/./g')
DOWJ=$(wget -qO- ${SITES[3]} | sed 's/<tr>/<tr>\n/g' | grep -A3 '<strong>Kurs</strong>' | grep -o -E "[0-9]+\.[0-9]+,[0-9]{2}" | tr -d '.' | tr ',' '.' | tail -1)
DAX=$(wget -qO- ${SITES[4]} | sed 's/<tr>/<tr>\n/g' | grep -A3 '<strong>Kurs</strong>' | grep -o -E "[0-9]+\.[0-9]+,[0-9]{2}" | tr -d '.' | tr ',' '.' | tail -1)
ATX=$(wget -qO- ${SITES[5]} | sed 's/<tr>/<tr>\n/g' | grep -A3 '<strong>Kurs</strong>' | grep -o -E "[0-9]+\.[0-9]+,[0-9]{2}" | tr -d '.' | tr ',' '.' | tail -1)
fi
fi
#if [ "$(cat ${BA_DATA} | grep -F "<td>${DATE}</td>")" == "" ]; then
# if [[ "${KURS_INET1}" != "" ]] && [[ "${KURS_INET2}" != "" ]] && [[ "${KURS_INET3}" != "" ]] && [[ "${DATE}" != "" ]]; then
# sed -i 's/<\/table>/<tr><td>'"${KURS_INET1}"'<\/td><td>'"${KURS_INET2}"'<\/td><td>'"${KURS_INET3}"'<\/td><td>'"${DATE}"'<\/td><\/tr><\/table>/g' ${BA_DATA}
# fi
IFS=$'\n'; set -f
KURSE_INET=("${KURS_INET1}" "${KURS_INET2}" "${KURS_INET3}" "${DOWJ}" "${DAX}" "${ATX}")
KURSE_LOCAL=($(cat ${BA_JS} | grep '.data' | rev | cut -d',' -f 1 | rev | sed 's/\];//g'))
DATE_LOCAL="$(cat ${BA_JS} | grep 'date' | rev | cut -d',' -f 1 | rev | sed 's/\];//g' | tr -d "\'")"
if ${DEBUG}; then
echo "${#KURSE_INET[@]} -eq ${#KURSE_LOCAL[@]}"
fi
ALL_THERE=true
for ((i=0;i<${#KURSE_INET[@]};i++)); do
if [[ "${KURSE_INET[$i]}" == "" ]]; then
ALL_THERE=false
if ${DEBUG}; then
echo "$i: ${KURSE_INET[$i]}"
fi
fi
done
if [[ "${ALL_THERE}" == "true" ]]; then
CHANGE=false
unset IFS; set +f
if ${DEBUG}; then
printf "Inet\t\tLocal\n"
fi
for ((i=0;i<${#KURSE_INET[@]};i++)); do
if ${DEBUG}; then
printf "%s\t\t%s\n" "${KURSE_INET[$i]}" "${KURSE_LOCAL[$i]}"
fi
if [ "${KURSE_INET[$i]}" != "${KURSE_LOCAL[$i]}" ]; then
CHANGE=true
printf "Diff: %s\t\t%s\n" "${KURSE_INET[$i]}" "${KURSE_LOCAL[$i]}"
fi
done
if [[ "${CHANGE}" == "true" ]]; then
if [[ "${DATE}" == "${DATE_LOCAL}" ]]; then
if ${DEBUG}; then echo "Change on same Date"; fi
sed -i 's/<tr><td>'"${KURS_LOCAL[0]}"'<\/td><td>'"${KURS_LOCAL[1]}"'<\/td><td>'"${KURS_LOCAL[2]}"'<\/td><td>'"${DATE}"'<\/td><\/tr>/<tr><td>'"${KURSE_INET[0]}"'<\/td><td>'"${KURSE_INET[1]}"'<\/td><td>'"${KURSE_INET[2]}"'<\/td><td>'"${DATE}"'<\/td><\/tr>/g' ${BA_DATA}
sed -i 's/\(fond_trad\.data.*\),[0-9]\+\.[0-9]\{2\}\];/\1,'"${KURSE_INET[0]}"'];/g' ${BA_JS}
sed -i 's/\(fond_dyn\.data.*\),[0-9]\+\.[0-9]\{2\}\];/\1,'"${KURSE_INET[1]}"'];/g' ${BA_JS}
sed -i 's/\(fond_climate\.data.*\),[0-9]\+\.[0-9]\{2\}\];/\1,'"${KURSE_INET[2]}"'];/g' ${BA_JS}
sed -i 's/\(fond_doj\.data.*\),[0-9]\+\.[0-9]\{2\}\];/\1,'"${KURSE_INET[3]}"'];/g' ${BA_JS}
sed -i 's/\(fond_dax\.data.*\),[0-9]\+\.[0-9]\{2\}\];/\1,'"${KURSE_INET[4]}"'];/g' ${BA_JS}
sed -i 's/\(fond_atx\.data.*\),[0-9]\+\.[0-9]\{2\}\];/\1,'"${KURSE_INET[5]}"'];/g' ${BA_JS}
touch ${BA_DATA}
touch ${BA_JS}
else
if ${DEBUG}; then echo "Change on New Date"; fi
sed -i 's/<\/table>/<tr><td>'"${KURSE_INET[0]}"'<\/td><td>'"${KURSE_INET[1]}"'<\/td><td>'"${KURSE_INET[2]}"'<\/td><td>'"${DATE}"'<\/td><\/tr><\/table>/g' ${BA_DATA}
## data.js ##
sed -i 's/\(fond_trad\.data.*\)\];/\1,'"${KURSE_INET[0]}"'];/g' ${BA_JS}
echo $?
sed -i 's/\(fond_dyn\.data.*\)\];/\1,'"${KURSE_INET[1]}"'];/g' ${BA_JS}
echo $?
sed -i 's/\(fond_climate\.data.*\)\];/\1,'"${KURSE_INET[2]}"'];/g' ${BA_JS}
echo $?
sed -i 's/\(date.*\)\];/\1,'"'${DATE}'"'];/g' ${BA_JS}
echo $?
sed -i 's/\(fond_doj\.data.*\)\];/\1,'"${KURSE_INET[3]}"'];/g' ${BA_JS}
echo $?
sed -i 's/\(fond_dax\.data.*\)\];/\1,'"${KURSE_INET[4]}"'];/g' ${BA_JS}
echo $?
sed -i 's/\(fond_atx\.data.*\)\];/\1,'"${KURSE_INET[5]}"'];/g' ${BA_JS}
echo $?
touch ${BA_DATA}
touch ${BA_JS}
fi
else
if ${DEBUG}; then echo No Change; fi
fi
fi
if [ "$(which syncNC)" != "" ]; then
syncNC > /dev/null 2>&1
fi