From d18c7723aa2a2e423650bcc99f7380e3fde55833 Mon Sep 17 00:00:00 2001 From: juanlf Date: Mon, 16 Jun 2025 20:40:42 +0000 Subject: [PATCH] Subir archivos a "/" --- cesion_root.sh | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ converter.sh | 9 ++++++ listar_repos.sh | 26 ++++++++++++++++ media.sh | 15 +++++++++ media2.sh | 3 ++ 5 files changed, 136 insertions(+) create mode 100644 cesion_root.sh create mode 100644 converter.sh create mode 100644 listar_repos.sh create mode 100644 media.sh create mode 100644 media2.sh diff --git a/cesion_root.sh b/cesion_root.sh new file mode 100644 index 0000000..0be6016 --- /dev/null +++ b/cesion_root.sh @@ -0,0 +1,83 @@ +#!/bin/bash + +# Variables +max_cesion=180 +user=$1 +horas=$2 +horas_default=12 + +# Chequeo de requisitos para su ejecución +if [ $(id -u) -ne 0 ] +then echo "ERROR. Se necesitan permisos de root" + exit 1 +fi + +systemctl is-active -q atd +if [ $? -ne 0 ] +then + echo "ERROR: el servicio ATD no está en ejecución" + exit 1 +fi + + +if ! [ -x /sbin/groupmems ] +then + echo "ERROR: No se puede ejecutar /sbin/groupmems" + exit 1 +fi + +if [ $# -ne 1 ] && [ $# -ne 2 ]; +then + echo "ERROR: número de parámetros incorrecto" + echo + echo "Uso: $0 USUARIO [HORAS]" + echo + echo "USUARIO: login de usuario a ceder permisos sudo" + echo "Horas: número de horas a mantener el permiso, por defecto 12h" + echo + echo + exit 1 +fi + + +getent passwd $user > /dev/null +if [ $? -ne 0 ] +then + echo "ERROR: el usuario $user no existe" + exit 1 +fi + + +if [ $# -eq 2 ] +then + if ! [[ $horas =~ ^[0-9]+$ ]] || [ $horas -lt 1 ] || [ $horas -gt $max_cesion ] + then + echo "ERROR: el número de horas debe estar entre 1 y $max_cesion" + echo + echo "Uso: $0 $user [HORAS]" + echo + echo + exit 1 + fi +else + horas=$horas_default +fi + + +# main script + +error_output=$(groupmems -g wheel -a $user 2>&1) +if [ $? -ne 0 ] +then + echo "ERROR: $error_output" +else + output=$(at 2>&1 now + $horas hours -M <&1 >/dev/null +END +) + echo "CESION SUDO OK" + echo "Usuario: $user" + echo "Fecha expiración: $output" + echo + +fi diff --git a/converter.sh b/converter.sh new file mode 100644 index 0000000..016f327 --- /dev/null +++ b/converter.sh @@ -0,0 +1,9 @@ +#/bin/zsh + +for i in *.avi +do + name=`echo $i | cut -f1 -d.` + name=`basename "$i" .avi` + + ffmpeg -i "$i" -vcodec libx264 -c:a aac "$name".mp4 && rm $i +done diff --git a/listar_repos.sh b/listar_repos.sh new file mode 100644 index 0000000..60c6a38 --- /dev/null +++ b/listar_repos.sh @@ -0,0 +1,26 @@ +#!/bin/bash + +REPO_DIR="/Volumes/Git-repos" +TMP_DIR="/tmp/git_inspect" + +mkdir -p "$TMP_DIR" + +for repo in "$REPO_DIR"/*.git; do + echo "📦 Repositorio: $(basename "$repo")" + cd "$repo" || continue + + for branch in $(git for-each-ref --format='%(refname:short)' refs/heads/); do + echo "├─ 🌿 Rama: $branch" + + last_commit=$(git log -1 --pretty=format:"%ad %an - %s" --date=short "$branch") + echo "│ └─ Último commit: $last_commit" + + # (Opcional) Listar archivos del commit HEAD de esa rama + echo "│ 📂 Archivos:" + git --work-tree="$TMP_DIR" checkout -f "$branch" --quiet + find "$TMP_DIR" -type f | sed 's|^|│ • |' + rm -rf "$TMP_DIR"/* + done + + echo +done diff --git a/media.sh b/media.sh new file mode 100644 index 0000000..5e96c14 --- /dev/null +++ b/media.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +IFS=$'\n' + +# accepts any list of files, eg. video_times *.{mp4,mov} +video_times() { +for file in $* ; do + duration=$(mediainfo --Output=JSON "$file" | jq -r '.media.track[] | select(."@type"=="General") | .Duration | tonumber | floor') + minutes=$(($duration / 60)) + seconds=$(($duration % 60)) + echo "$file: ${minutes}m${seconds}s" +done +} + + video_times $* diff --git a/media2.sh b/media2.sh new file mode 100644 index 0000000..011fcb9 --- /dev/null +++ b/media2.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +ffprobe -v error -select_streams v:0 -show_entries stream=bitrate,,width,height -of csv=s=x:p=0 -- "$1"