Tidying mirrors

This commit is contained in:
Bob Mottram 2016-10-13 22:26:09 +01:00
parent 9cf8113211
commit 784c572279
2 changed files with 15 additions and 38 deletions

View File

@ -51,24 +51,19 @@ if [ ! -f $MAIN_COMMAND ]; then
MAIN_COMMAND=/usr/bin/${PROJECT_NAME}
fi
REPOS=($(cat ${MAIN_COMMAND} /usr/share/${PROJECT_NAME}/utils/${MAIN_COMMAND}-utils-* /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-* | grep "_REPO=\"" | grep -v "(cat " | uniq -u | sed 's|${PROJECT_NAME}|'"${PROJECT_NAME}"'|g'))
REPOS=($(cat ${MAIN_COMMAND} /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-* /usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-* | grep "_REPO=\"" | grep -v "(cat " | uniq -u | sed 's|${PROJECT_NAME}|'"${PROJECT_NAME}"'|g'))
UTILS_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
for f in $UTILS_FILES
do
source $f
done
# obtain the mirrors password if it exists
if [ -f $CONFIGURATION_FILE ]; then
if ! grep -q "MY_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
MY_MIRRORS_PASSWORD=$(grep "MY_MIRRORS_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if ! grep -q "FRIENDS_MIRRORS_SERVER" $CONFIGURATION_FILE; then
FRIENDS_MIRRORS_SERVER=$(grep "FRIENDS_MIRRORS_SERVER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if ! grep -q "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
FRIENDS_MIRRORS_PASSWORD=$(grep "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if ! grep -q "FRIENDS_MIRRORS_SSH_PORT" $CONFIGURATION_FILE; then
FRIENDS_MIRRORS_SSH_PORT=$(grep "FRIENDS_MIRRORS_SSH_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
fi
read_config_param MY_MIRRORS_PASSWORD
read_config_param FRIENDS_MIRRORS_SERVER
read_config_param FRIENDS_MIRRORS_PASSWORD
read_config_param FRIENDS_MIRRORS_SSH_PORT
function show_help {
echo ''
@ -106,13 +101,7 @@ function create_mirrors_user {
rm -rf /home/mirrors/*
# store the mirrors password
if [ -f $CONFIGURATION_FILE ]; then
if ! grep -q "MY_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
echo "MY_MIRRORS_PASSWORD=$MY_MIRRORS_PASSWORD" >> $CONFIGURATION_FILE
else
sed -i "s|MY_MIRRORS_PASSWORD=.*|MY_MIRRORS_PASSWORD=${MY_MIRRORS_PASSWORD}|g" $CONFIGURATION_FILE
fi
fi
write_config_param "MY_MIRRORS_PASSWORD" "${MY_MIRRORS_PASSWORD}"
}
function enable_mirrors_via_onion {
@ -199,24 +188,12 @@ case $key in
-m|--mypass|--mypassword)
shift
MY_MIRRORS_PASSWORD="$1"
if [ -f $CONFIGURATION_FILE ]; then
if ! grep -q "MY_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
echo "MY_MIRRORS_PASSWORD=$MY_MIRRORS_PASSWORD" >> $CONFIGURATION_FILE
else
sed -i "s|MY_MIRRORS_PASSWORD=.*|MY_MIRRORS_PASSWORD=${MY_MIRRORS_PASSWORD}|g" $CONFIGURATION_FILE
fi
fi
write_config_param "MY_MIRRORS_PASSWORD" "${MY_MIRRORS_PASSWORD}"
;;
-p|--pass|--password)
shift
FRIENDS_MIRRORS_PASSWORD="$1"
if [ -f $CONFIGURATION_FILE ]; then
if ! grep -q "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
echo "FRIENDS_MIRRORS_PASSWORD=$FRIENDS_MIRRORS_PASSWORD" >> $CONFIGURATION_FILE
else
sed -i "s|FRIENDS_MIRRORS_PASSWORD=.*|FRIENDS_MIRRORS_PASSWORD=${FRIENDS_MIRRORS_PASSWORD}|g" $CONFIGURATION_FILE
fi
fi
write_config_param "FRIENDS_MIRRORS_PASSWORD" "${FRIENDS_MIRRORS_PASSWORD}"
;;
-n|--new)
shift

View File

@ -30,10 +30,10 @@
PROJECT_NAME='freedombone'
PROJECT_DIR="/root/${PROJECT_NAME}"
PROJECT_DIR="$HOME/${PROJECT_NAME}"
# An optional configuration file which overrides some of these variables
CONFIGURATION_FILE="/root/${PROJECT_NAME}.cfg"
CONFIGURATION_FILE="$HOME/${PROJECT_NAME}.cfg"
PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"