Script para criação de pacotes auto extrator.
Publicado por Jeferson Alberi da Silva 10/01/2006
[ Hits: 5.800 ]
Download createAutoExtractor.sh
Script shell para criação de pacote auto extrator com opção de adicionar comandos de pré-install e post-install.
Para maiores informações consulte o help do mesmo.
#!/bin/bash
# Jeferson A SILVA
# 22/09/2005
AUX_A="script1.sh_tmp"
AUX_B="script2.sh_tmp"
Usage(){
echo -e "Usage:"
echo -e "\t--preinst\t- Arquivo texto ou .sh com os comandos (script) pré-instalacao."
echo -e "\t--posinst\t- Arquivo texto ou .sh com os comandos (script) pós-instalacao."
echo -e "\t--input\t\t- Obrigatorio - Arquivo .tar.gz com arquivos e/ou binarios."
echo -e "\t--output\t- Obrigatorio - Nome do script de saida. E.: meushell.sh"
echo -e "\t--help\t\t- Utilize para obter informações sobre a utilização deste."
echo -e "Exemplo:"
echo -e "\t$0 --input=teste.tar.gz --output=teste.sh"
echo -e "\t$0 --preinst=preinst.sh --posinst=postinst.sh --input=files.tar.gz --output=meushell.sh"
exit 0
}
while [ $# -gt 0 ]
do
case $1 in
--preinst*)
if echo $1 | grep -q '=' >/dev/null
then
PREINST=`echo $1 | sed 's/^--preinst=//'`
else
PREINST=$2
shift
fi
;;
--posinst*)
if echo $1 | grep -q '=' >/dev/null
then
POSINST=`echo $1 | sed 's/^--posinst=//'`
else
POSINST=$2
shift
fi
;;
--input*)
if echo $1 | grep -q '=' >/dev/null
then
INPUT=`echo $1 | sed 's/^--input=//'`
else
INPUT=$2
shift
fi
;;
--output*)
if echo $1 | grep -q '=' >/dev/null
then
OUTPUT=`echo $1 | sed 's/^--output=//'`
else
OUTPUT=$2
shift
fi
;;
--help|-help|--h|--info|-info*)
Usage
;;
*)
echo "Opcao invalida utilizada na funcao $(basename $0) - $1"
Usage
;;
esac
shift
done
if [ -e "$INPUT" ] && [ ! -z "$OUTPUT" ]
then
echo '#!/bin/bash' > ${AUX_A}
echo "" >> ${AUX_A}
if [ ! -z "${PREINST}" ] && [ -e "${PREINST}" ]
then
echo "# Pré Install" >> ${AUX_A}
cat ${PREINST} | grep -v '#!/bin/bash' >> ${AUX_A}
else
echo "ATENÇÃO - pré-install não definido ou não encontrado ${PREINST}"
fi
echo "# Install" >> ${AUX_A}
echo "tail -n +{NUMBER} \$0 > ${INPUT}" >> ${AUX_A}
echo "tar zxf ${INPUT}" >> ${AUX_A}
echo "rm -f ${INPUT}" >> ${AUX_A}
if [ ! -z "${POSINST}" ] && [ -e "${POSINST}" ]
then
echo "# Pós Install" >> ${AUX_A}
cat ${POSINST} | grep -v '#!/bin/bash' >> ${AUX_A}
else
echo "ATENÇÃO - pós-install não definido ou não encontrado ${POSINST}"
fi
echo "" >> ${AUX_A}
echo "exit 0" >> ${AUX_A}
LINE=$(($(wc -l ${AUX_A} | awk '{print $1}')+1))
sed -e "s/{NUMBER}/${LINE}/g" ${AUX_A} > ${AUX_B}
mv -f ${AUX_B} ${AUX_A}
cat "${AUX_A}" "${INPUT}" > ${OUTPUT}
chmod +x ${OUTPUT}
rm -f ${AUX_A}
echo "Script gerado em ${OUTPUT}"
else
Usage
fi
Script para construção de VPN-SSL
Limpar o lixo das caixas de e-mail dos usuários que usam Maildir...
syncnow - sincronizar diretórios com servidor local
XFCE - quase um Gnome ou Plasma mas muito mais leve
LXQT - funcional para máquinas pererecas e usuários menos exigentes
Instalação do K3s Single-Node com Rancher no Ubuntu 24.04
Usei o NotebookLM para Auditar Logs do Linux
Cinnamon seria a aposta acertada frente às outras interfaces gráficas mais populares?
Samba 4 AD-DC 2026: Como instalar e configurar um Active Directory (via APT-GET)
[Resolvido] Sumiço de redes e micro quedas no iwd/iwgtk (Realtek rtw88)
Como Configurar DNS Reverso (PTR) em Ambientes Linux e Microsoft
Preparando o Ambiente para Administrar o Samba 4 a partir do Windows com RSAT
Problema ao instalar Linux Mint. (1)
Midia de instalação LM-21.3 não inicializa (11)
A diferença entre a fala de um Samuel e a fala de alguém que conhece o... (9)









