68 lines
996 B
Bash
Executable File
68 lines
996 B
Bash
Executable File
#!/bin/bash
|
|
|
|
# Checking the input arguments.
|
|
|
|
usage ()
|
|
{
|
|
echo "Usage: $0 [-c codename] packages"
|
|
exit 1
|
|
}
|
|
|
|
. /usr/share/dev-tools/load-config
|
|
|
|
while getopts ":c:" option
|
|
do
|
|
case $option in
|
|
\?|:)
|
|
usage
|
|
;;
|
|
esac
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
if [ ! $1 ]
|
|
then
|
|
usage
|
|
fi
|
|
|
|
# Checking that all files exist.
|
|
|
|
for package in $@
|
|
do
|
|
if [ ! -r $package ]
|
|
then
|
|
echo "$0: File doesn't exists: $package"
|
|
exit 2
|
|
fi
|
|
done
|
|
|
|
# Checking that SSH key file exists.
|
|
|
|
if [ ! -r $sshKeyFile ]
|
|
then
|
|
echo "$0: Can't find the SSH key file: $sshKeyFile"
|
|
exit 3
|
|
fi
|
|
|
|
# Uploading and adding the packages to the repository.
|
|
|
|
for package in $@
|
|
do
|
|
dest=/tmp/`basename $package`
|
|
|
|
scp -i $sshKeyFile $package $sshUser@$sshHost:$dest
|
|
|
|
if [ "$?" -eq "0" ]
|
|
then
|
|
ssh $sshHost -n -i $sshKeyFile -l $sshUser \
|
|
"reprepro -b $repoDir includedeb $codename $dest; rm -f $dest"
|
|
else
|
|
echo "An error occurred uploading the package $package"
|
|
exit 4
|
|
fi
|
|
done
|
|
|
|
#echo "Press any key to continue..."
|
|
#read -n 0 -ers
|