Skip to content

Instantly share code, notes, and snippets.

@kphrx
Last active December 29, 2016 03:44
Show Gist options
  • Save kphrx/8a1ceed2d93140130742650a8721498d to your computer and use it in GitHub Desktop.
Save kphrx/8a1ceed2d93140130742650a8721498d to your computer and use it in GitHub Desktop.
#!/bin/bash
####################
# #
# (C) 2015 kPherox #
# #
####################
CMDNAME=`basename $0`
DEBDIR="./download"
REPODIR="./"
while getopts cod:r:z: OPT
do
case $OPT in
"c" ) FLG_c="TRUE"
;;
"d" ) FLG_d="TRUE"
DEBDIR="$OPTARG"
;;
"o" ) FLG_o="TRUE"
;;
"r" ) FLG_r="TRUE"
REPODIR="$OPTARG"
;;
"z" ) FLG_z="TRUE"
ZIPPING="$OPTARG"
;;
* ) echo "1.Usage: $CMDNAME [-co] ... [-d <DEBファイルのディレクトリ>] [-r <作業ディレクトリ>] [-z <圧縮形式>]" 1>&2
exit 1
;;
esac
done
cat <<__FIR__
<<Packages File Maker>>
Start making Packages file!
__FIR__
sleep 1s
cd ${REPODIR}
echo "Now Make Packages..."
apt-ftparchive packages ./${DEBDIR} > Packages
sleep 1s
echo "Finish!"
if [ "$FLG_c" = "TRUE" ]; then
cat <<__CNTL__
Counter script is using PHP & MySQL
Sample
PHP script file is "https://gist.github.com/kirb/1922421/raw/8092ec742cae9be020944d18f0e729000ba23413/counter.php"
SQL file is "https://gist.github.com/kirb/1922421/raw/8092ec742cae9be020944d18f0e729000ba23413/downloads.sql"
__CNTL__
echo "Now Set Counter..."
sleep 1s
sed -i "s/\${DEBDIR}\//counter.php?filename=/g" Packages
sleep 1s
echo "Finish!"
fi
if [ "$FLG_o" = "TRUE" ]; then
case ${ZIPPING} in
"gzip" ) ZIP="gzip -f"
echo "Now Packages Gzipping..."
;;
"bzip" ) ZIP="bzip2 -f"
echo "Now Packages Bzipping..."
;;
* )
;;
esac
sleep 1s
elif [ "$FLG_z" = "TRUE" ]; then
case ${ZIPPING} in
"gzip" ) ZIP="gzip"
echo "Now Packages Gzipping..."
;;
"bzip" ) ZIP="bzip2"
echo "Now Packages Bzipping..."
;;
* )
;;
esac
sleep 1s
fi
if [ "$FLG_z" = "TRUE" ]; then
${ZIP} Packages
sleep 1s
echo "Finish!"
fi
sleep 1s
echo "All End"
sleep 0.3s
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment