Subir archivos a "/"
This commit is contained in:
83
cesion_root.sh
Normal file
83
cesion_root.sh
Normal file
@ -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 <<END | tail -1 | grep -oP '(?<=at).*'
|
||||
groupmems -g wheel -d $user 2>&1 >/dev/null
|
||||
END
|
||||
)
|
||||
echo "CESION SUDO OK"
|
||||
echo "Usuario: $user"
|
||||
echo "Fecha expiración: $output"
|
||||
echo
|
||||
|
||||
fi
|
||||
9
converter.sh
Normal file
9
converter.sh
Normal file
@ -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
|
||||
26
listar_repos.sh
Normal file
26
listar_repos.sh
Normal file
@ -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
|
||||
15
media.sh
Normal file
15
media.sh
Normal file
@ -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 $*
|
||||
Reference in New Issue
Block a user