Rename troves to mirrors

This commit is contained in:
Bob Mottram 2016-02-01 10:05:29 +00:00
parent 2c211a009e
commit 2274a608cf
29 changed files with 489 additions and 489 deletions

View File

@ -12,13 +12,13 @@
"Import keys from USB drive/s": "",
"Retrieve keys from friends servers": "",
"Freedombone Control Panel": "",
"Main Repository (Trove)": "",
"If you do not wish to use the default repositories they can be obtained from another ${PROJECT_NAME} server acting as a trove.\\n\\nA trove is a mirrored collection of git repositories for systems which are not yet packaged for Debian.\\n\\nTo use the defaults just select Ok.": "",
"Main Repository (Mirrors)": "",
"If you do not wish to use the default repositories they can be obtained from mirrored repos on another ${PROJECT_NAME} system.\\n\\nThe repositories are for applications which are not yet packaged for Debian.\\n\\nTo use the defaults just select Ok.": "",
"URL:": "",
"SSH Port:": "",
"Password:": "",
"Main Repository": "",
"Main repository set to $FRIENDS_TROVE_SERVER": "",
"Main repository set to $FRIENDS_MIRRORS_SERVER": "",
"Select your language:": "",
"English": "",
"French": "",

View File

@ -3,13 +3,13 @@
"Check for updates": "",
"Upgrade script was not found": "",
"Freedombone Control Panel": "",
"Main Repository (Trove)": "",
"If you do not wish to use the default repositories they can be obtained from another ${PROJECT_NAME} server acting as a trove.\\n\\nA trove is just a mirrored collection of git repositories.": "",
"Main Repository (Mirrors)": "",
"If you do not wish to use the default repositories they can be obtained from mirrors on another ${PROJECT_NAME} server.": "",
"URL:": "",
"SSH Port:": "",
"Password:": "",
"Main Repository": "",
"Main repository set to $FRIENDS_TROVE_SERVER": "",
"Main repository set to $FRIENDS_MIRRORS_SERVER": "",
"Add new user": "",
"Username:": "",
"ssh public key (optional):": "",
@ -179,7 +179,7 @@
"Logging on/off": "",
"Ping enable/disable": "",
"Security Settings": "",
"Set the main repository (Trove)": "",
"Set the main repository (repo mirrors)": "",
"Media menu": "",
"IRC menu": ""
}

View File

@ -0,0 +1,8 @@
{
"${PROJECT_NAME}-mirrors --sync [domain/url] -p [password]": "",
" -p|--password [yes|no] Friend's mirrors user password": "",
" -m|--mypassword [yes|no] Local mirrors user password": "",
" --port [number] Friend's server ssh port number": "",
" -s|--sync [domain] Friend's server domain to sync with": "",
"WARNING: failed to mirror repo ${repo_url}": ""
}

View File

@ -1,8 +0,0 @@
{
"${PROJECT_NAME}-trove --sync [domain/url] -p [password]": "",
" -p|--password [yes|no] Friend's trove user password": "",
" -m|--mypassword [yes|no] Local trove user password": "",
" --port [number] Friend's server ssh port number": "",
" -s|--sync [domain] Friend's server domain to sync with": "",
"WARNING: failed to mirror repo ${repo_url}": ""
}

Binary file not shown.

View File

@ -12,13 +12,13 @@
"Import keys from USB drive/s": "",
"Retrieve keys from friends servers": "",
"Freedombone Control Panel": "",
"Main Repository (Trove)": "",
"If you do not wish to use the default repositories they can be obtained from another ${PROJECT_NAME} server acting as a trove.\\n\\nA trove is a mirrored collection of git repositories for systems which are not yet packaged for Debian.\\n\\nTo use the defaults just select Ok.": "",
"Main Repository (Mirrors)": "",
"If you do not wish to use the default repositories they can be obtained from mirrored repos on another ${PROJECT_NAME} system.\\n\\nThe repositories are for applications which are not yet packaged for Debian.\\n\\nTo use the defaults just select Ok.": "",
"URL:": "",
"SSH Port:": "",
"Password:": "",
"Main Repository": "",
"Main repository set to $FRIENDS_TROVE_SERVER": "",
"Main repository set to $FRIENDS_MIRRORS_SERVER": "",
"Select your language:": "",
"English": "",
"French": "",

View File

@ -3,13 +3,13 @@
"Check for updates": "",
"Upgrade script was not found": "",
"Freedombone Control Panel": "",
"Main Repository (Trove)": "",
"If you do not wish to use the default repositories they can be obtained from another ${PROJECT_NAME} server acting as a trove.\\n\\nA trove is just a mirrored collection of git repositories.": "",
"Main Repository (Mirrors)": "",
"If you do not wish to use the default repositories they can be obtained from mirrors on another ${PROJECT_NAME} server.": "",
"URL:": "",
"SSH Port:": "",
"Password:": "",
"Main Repository": "",
"Main repository set to $FRIENDS_TROVE_SERVER": "",
"Main repository set to $FRIENDS_MIRRORS_SERVER": "",
"Add new user": "",
"Username:": "",
"ssh public key (optional):": "",
@ -179,7 +179,7 @@
"Logging on/off": "",
"Ping enable/disable": "",
"Security Settings": "",
"Set the main repository (Trove)": "",
"Set the main repository (repo mirrors)": "",
"Media menu": "",
"IRC menu": ""
}

View File

@ -0,0 +1,8 @@
{
"${PROJECT_NAME}-mirrors --sync [domain/url] -p [password]": "",
" -p|--password [yes|no] Friend's mirrors user password": "",
" -m|--mypassword [yes|no] Local mirrors user password": "",
" --port [number] Friend's server ssh port number": "",
" -s|--sync [domain] Friend's server domain to sync with": "",
"WARNING: failed to mirror repo ${repo_url}": ""
}

View File

@ -1,8 +0,0 @@
{
"${PROJECT_NAME}-trove --sync [domain/url] -p [password]": "",
" -p|--password [yes|no] Friend's trove user password": "",
" -m|--mypassword [yes|no] Local trove user password": "",
" --port [number] Friend's server ssh port number": "",
" -s|--sync [domain] Friend's server domain to sync with": "",
"WARNING: failed to mirror repo ${repo_url}": ""
}

Binary file not shown.

View File

@ -12,13 +12,13 @@
"Import keys from USB drive/s": "",
"Retrieve keys from friends servers": "",
"Freedombone Control Panel": "",
"Main Repository (Trove)": "",
"If you do not wish to use the default repositories they can be obtained from another ${PROJECT_NAME} server acting as a trove.\\n\\nA trove is a mirrored collection of git repositories for systems which are not yet packaged for Debian.\\n\\nTo use the defaults just select Ok.": "",
"Main Repository (Mirrors)": "",
"If you do not wish to use the default repositories they can be obtained from mirrored repos on another ${PROJECT_NAME} system.\\n\\nThe repositories are for applications which are not yet packaged for Debian.\\n\\nTo use the defaults just select Ok.": "",
"URL:": "",
"SSH Port:": "",
"Password:": "",
"Main Repository": "",
"Main repository set to $FRIENDS_TROVE_SERVER": "",
"Main repository set to $FRIENDS_MIRRORS_SERVER": "",
"Select your language:": "",
"English": "",
"French": "",

View File

@ -3,13 +3,13 @@
"Check for updates": "",
"Upgrade script was not found": "",
"Freedombone Control Panel": "",
"Main Repository (Trove)": "",
"If you do not wish to use the default repositories they can be obtained from another ${PROJECT_NAME} server acting as a trove.\\n\\nA trove is just a mirrored collection of git repositories.": "",
"Main Repository (Mirrors)": "",
"If you do not wish to use the default repositories they can be obtained from mirrors on another ${PROJECT_NAME} server.": "",
"URL:": "",
"SSH Port:": "",
"Password:": "",
"Main Repository": "",
"Main repository set to $FRIENDS_TROVE_SERVER": "",
"Main repository set to $FRIENDS_MIRRORS_SERVER": "",
"Add new user": "",
"Username:": "",
"ssh public key (optional):": "",
@ -179,7 +179,7 @@
"Logging on/off": "",
"Ping enable/disable": "",
"Security Settings": "",
"Set the main repository (Trove)": "",
"Set the main repository (repo mirrors)": "",
"Media menu": "",
"IRC menu": ""
}

View File

@ -0,0 +1,8 @@
{
"${PROJECT_NAME}-mirrors --sync [domain/url] -p [password]": "",
" -p|--password [yes|no] Friend's mirrors user password": "",
" -m|--mypassword [yes|no] Local mirrors user password": "",
" --port [number] Friend's server ssh port number": "",
" -s|--sync [domain] Friend's server domain to sync with": "",
"WARNING: failed to mirror repo ${repo_url}": ""
}

View File

@ -1,8 +0,0 @@
{
"${PROJECT_NAME}-trove --sync [domain/url] -p [password]": "",
" -p|--password [yes|no] Friend's trove user password": "",
" -m|--mypassword [yes|no] Local trove user password": "",
" --port [number] Friend's server ssh port number": "",
" -s|--sync [domain] Friend's server domain to sync with": "",
"WARNING: failed to mirror repo ${repo_url}": ""
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -88,14 +88,14 @@ CONFIGURATION_FILE="${PROJECT_NAME}.cfg"
SSH_PORT=2222
IRC_PORT=6697
# password used for accessing your repo trove
MY_TROVE_PASSWORD=
# friend's repo trove
FRIENDS_TROVE_PASSWORD=
FRIENDS_TROVE_SERVER=
FRIENDS_TROVE_SSH_PORT=2222
# password used for accessing your repo mirrors
MY_MIRRORS_PASSWORD=
# friend's repo mirrors
FRIENDS_MIRRORS_PASSWORD=
FRIENDS_MIRRORS_SERVER=
FRIENDS_MIRRORS_SSH_PORT=2222
# This isn't used here, but is included for trove creation purposes
# This isn't used here, but is included for mirrors creation purposes
LETSENCRYPT_REPO="https://github.com/letsencrypt/letsencrypt"
# An optional password to log into IRC. This applies to all users
@ -544,11 +544,11 @@ function git_clone {
repo_url="$1"
destination_dir="$2"
if [[ "$repo_url" == "ssh:"* ]]; then
if [ "${FRIENDS_TROVE_SERVER}" ]; then
if [ ${#FRIENDS_TROVE_SERVER} -gt 2 ]; then
if [ "$FRIENDS_TROVE_PASSWORD" ]; then
if [ ${#FRIENDS_TROVE_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_TROVE_PASSWORD" git clone "$repo_url" "$destination_dir"
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git clone "$repo_url" "$destination_dir"
return
fi
fi
@ -566,11 +566,11 @@ function git_pull {
git stash
git remote set-url origin $1
git checkout master
if [ "${FRIENDS_TROVE_SERVER}" ]; then
if [ ${#FRIENDS_TROVE_SERVER} -gt 2 ]; then
if [ "$FRIENDS_TROVE_PASSWORD" ]; then
if [ ${#FRIENDS_TROVE_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_TROVE_PASSWORD" git pull
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git pull
if [ $2 ]; then
git checkout $2 -b $2
fi
@ -957,24 +957,24 @@ function parse_args {
function read_repo_servers {
if [ -f $CONFIGURATION_FILE ]; then
if grep -q "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE; then
FRIENDS_TROVE_SERVER=$(grep "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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_TROVE_SSH_PORT" $CONFIGURATION_FILE; then
FRIENDS_TROVE_SSH_PORT=$(grep "FRIENDS_TROVE_SSH_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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
if grep -q "MY_TROVE_PASSWORD" $CONFIGURATION_FILE; then
MY_TROVE_PASSWORD=$(grep "MY_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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_TROVE_PASSWORD" $CONFIGURATION_FILE; then
FRIENDS_TROVE_PASSWORD=$(grep "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
if grep -q "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
FRIENDS_MIRRORS_PASSWORD=$(grep "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
fi
if [ ! $FRIENDS_TROVE_SERVER ]; then
if [ ! $FRIENDS_MIRRORS_SERVER ]; then
return
fi
if [ ${#FRIENDS_TROVE_SERVER} -lt 2 ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -lt 2 ]; then
return
fi
@ -988,8 +988,8 @@ function read_repo_servers {
for line in "${REPOS[@]}"
do
repo_name=$(echo "$line" | awk -F '=' '{print $1}')
trove_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
friends_repo_url="ssh://trove@${FRIENDS_TROVE_SERVER}:${FRIENDS_TROVE_SSH_PORT}/home/trove/${trove_name}"
mirrors_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
friends_repo_url="ssh://mirrors@${FRIENDS_MIRRORS_SERVER}:${FRIENDS_MIRRORS_SSH_PORT}/home/mirrors/${mirrors_name}"
${repo_name}="${friends_repo_url}"
done
}
@ -2261,12 +2261,12 @@ function mesh_cjdns {
echo 'mesh_cjdns' >> $COMPLETION_FILE
}
function create_trove {
if grep -Fxq "create_trove" $COMPLETION_FILE; then
function create_mirrors {
if grep -Fxq "create_mirrors" $COMPLETION_FILE; then
return
fi
${PROJECT_NAME}-trove
echo 'create_trove' >> $COMPLETION_FILE
${PROJECT_NAME}-mirrors
echo 'create_mirrors' >> $COMPLETION_FILE
}
function mesh_cjdns_tools {
@ -4768,7 +4768,7 @@ function spam_filtering {
echo '#!/bin/bash' > /usr/bin/filterspam
echo 'for d in /home/*/ ; do' >> /usr/bin/filterspam
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/filterspam
echo ' if [[ $USERNAME != "git" && $USERNAME != "trove" ]]; then' >> /usr/bin/filterspam
echo ' if [[ $USERNAME != "git" && $USERNAME != "mirrors" ]]; then' >> /usr/bin/filterspam
echo ' MAILDIR=/home/$USERNAME/Maildir/.learn-spam' >> /usr/bin/filterspam
echo ' if [ ! -d "$MAILDIR" ]; then' >> /usr/bin/filterspam
echo ' exit' >> /usr/bin/filterspam
@ -4790,7 +4790,7 @@ function spam_filtering {
echo '#!/bin/bash' > /usr/bin/filterham
echo 'for d in /home/*/ ; do' >> /usr/bin/filterham
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/filterham
echo ' if [[ $USERNAME != "git" && $USERNAME != "trove" ]]; then' >> /usr/bin/filterham
echo ' if [[ $USERNAME != "git" && $USERNAME != "mirrors" ]]; then' >> /usr/bin/filterham
echo ' MAILDIR=/home/$USERNAME/Maildir/.learn-ham' >> /usr/bin/filterham
echo ' if [ ! -d "$MAILDIR" ]; then' >> /usr/bin/filterham
echo ' exit' >> /usr/bin/filterham
@ -9996,7 +9996,7 @@ remove_instructions_from_motd
check_hwrng
search_for_attached_usb_drive
regenerate_ssh_keys
create_trove
create_mirrors
create_upgrade_script
letsencrypt_renewals
install_zeronet

View File

@ -50,31 +50,31 @@ INSTALL_DIR=/root/build
LETSENCRYPT_SERVER='https://acme-v01.api.letsencrypt.org/directory'
LETSENCRYPT_REPO="https://github.com/letsencrypt/letsencrypt"
MY_EMAIL_ADDRESS=
FRIENDS_TROVE_SERVER=
FRIENDS_TROVE_PASSWORD=
FRIENDS_TROVE_SSH_PORT=
MY_TROVE_PASSWORD=
FRIENDS_MIRRORS_SERVER=
FRIENDS_MIRRORS_PASSWORD=
FRIENDS_MIRRORS_SSH_PORT=
MY_MIRRORS_PASSWORD=
function read_repo_servers {
if [ -f $CONFIGURATION_FILE ]; then
if grep -q "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE; then
FRIENDS_TROVE_SERVER=$(grep "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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_TROVE_SSH_PORT" $CONFIGURATION_FILE; then
FRIENDS_TROVE_SSH_PORT=$(grep "FRIENDS_TROVE_SSH_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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
if grep -q "MY_TROVE_PASSWORD" $CONFIGURATION_FILE; then
MY_TROVE_PASSWORD=$(grep "MY_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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_TROVE_PASSWORD" $CONFIGURATION_FILE; then
FRIENDS_TROVE_PASSWORD=$(grep "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
if grep -q "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
FRIENDS_MIRRORS_PASSWORD=$(grep "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
fi
if [ ! $FRIENDS_TROVE_SERVER ]; then
if [ ! $FRIENDS_MIRRORS_SERVER ]; then
return
fi
if [ ${#FRIENDS_TROVE_SERVER} -lt 2 ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -lt 2 ]; then
return
fi
@ -88,8 +88,8 @@ function read_repo_servers {
for line in "${REPOS[@]}"
do
repo_name=$(echo "$line" | awk -F '=' '{print $1}')
trove_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
friends_repo_url="ssh://trove@${FRIENDS_TROVE_SERVER}:${FRIENDS_TROVE_SSH_PORT}/home/trove/${trove_name}"
mirrors_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
friends_repo_url="ssh://mirrors@${FRIENDS_MIRRORS_SERVER}:${FRIENDS_MIRRORS_SSH_PORT}/home/mirrors/${mirrors_name}"
${repo_name}="${friends_repo_url}"
done
}
@ -98,11 +98,11 @@ function git_clone {
repo_url="$1"
destination_dir="$2"
if [[ "$repo_url" == "ssh:"* ]]; then
if [ "${FRIENDS_TROVE_SERVER}" ]; then
if [ ${#FRIENDS_TROVE_SERVER} -gt 2 ]; then
if [ "$FRIENDS_TROVE_PASSWORD" ]; then
if [ ${#FRIENDS_TROVE_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_TROVE_PASSWORD" git clone "$repo_url" "$destination_dir"
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git clone "$repo_url" "$destination_dir"
return
fi
fi
@ -120,11 +120,11 @@ function git_pull {
git stash
git remote set-url origin $1
git checkout master
if [ "${FRIENDS_TROVE_SERVER}" ]; then
if [ ${#FRIENDS_TROVE_SERVER} -gt 2 ]; then
if [ "$FRIENDS_TROVE_PASSWORD" ]; then
if [ ${#FRIENDS_TROVE_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_TROVE_PASSWORD" git pull
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git pull
if [ $2 ]; then
git checkout $2 -b $2
fi

View File

@ -35,7 +35,7 @@ export TEXTDOMAINDIR="/usr/share/locale"
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USERNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USERNAME != "mirrors" ]]; then
# for every user who has a mail directory
if [ -d /home/$USERNAME/Maildir ]; then
MUTTRC=/home/$USERNAME/.muttrc

View File

@ -265,7 +265,7 @@ function backup_users {
# Backup user files
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USERNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USERNAME != "mirrors" ]]; then
# Backup any gpg keys
if [ -d /home/$USERNAME/.gnupg ]; then

View File

@ -178,7 +178,7 @@ function backup_configuration {
function backup_users {
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USERNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USERNAME != "mirrors" ]]; then
# personal settings
if [ -d /home/$USERNAME/personal ]; then
@ -604,7 +604,7 @@ do
# Social key management
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USERNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USERNAME != "mirrors" ]]; then
disperse_key_shares $USERNAME $REMOTE_DOMAIN $REMOTE_SSH_PORT "$REMOTE_PASSWORD" $REMOTE_SERVER
fi
done

View File

@ -111,11 +111,11 @@ MINIMAL_INSTALL="yes"
DEFAULT_LANGUAGE='en_GB.UTF-8'
ONION_ONLY="no"
# Trove settings
FRIENDS_TROVE_SERVER=
FRIENDS_TROVE_SSH_PORT=2222
FRIENDS_TROVE_PASSWORD=
MY_TROVE_PASSWORD=
# Mirrors settings
FRIENDS_MIRRORS_SERVER=
FRIENDS_MIRRORS_SSH_PORT=2222
FRIENDS_MIRRORS_PASSWORD=
MY_MIRRORS_PASSWORD=
function show_help {
echo ''
@ -288,14 +288,14 @@ function save_configuration_file {
fi
echo "ONION_ONLY=$ONION_ONLY" >> $CONFIGURATION_FILE
if [ $FRIENDS_TROVE_SERVER ]; then
echo "FRIENDS_TROVE_SERVER=$FRIENDS_TROVE_SERVER" >> $CONFIGURATION_FILE
if [ $FRIENDS_MIRRORS_SERVER ]; then
echo "FRIENDS_MIRRORS_SERVER=$FRIENDS_MIRRORS_SERVER" >> $CONFIGURATION_FILE
fi
if [ $FRIENDS_TROVE_SSH_PORT ]; then
echo "FRIENDS_TROVE_SSH_PORT=$FRIENDS_TROVE_SSH_PORT" >> $CONFIGURATION_FILE
if [ $FRIENDS_MIRRORS_SSH_PORT ]; then
echo "FRIENDS_MIRRORS_SSH_PORT=$FRIENDS_MIRRORS_SSH_PORT" >> $CONFIGURATION_FILE
fi
if [ $FRIENDS_TROVE_PASSWORD ]; then
echo "FRIENDS_TROVE_PASSWORD=$FRIENDS_TROVE_PASSWORD" >> $CONFIGURATION_FILE
if [ $FRIENDS_MIRRORS_PASSWORD ]; then
echo "FRIENDS_MIRRORS_PASSWORD=$FRIENDS_MIRRORS_PASSWORD" >> $CONFIGURATION_FILE
fi
}
@ -532,40 +532,40 @@ function set_main_repo {
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"Main Repository (Trove)" \
--form $"If you do not wish to use the default repositories they can be obtained from another ${PROJECT_NAME} server acting as a trove.\n\nA trove is a mirrored collection of git repositories for systems which are not yet packaged for Debian.\n\nTo use the defaults just select Ok." 18 65 4 \
$"URL:" 1 1 "$FRIENDS_TROVE_SERVER" 1 18 40 18 \
$"SSH Port:" 2 1 "$FRIENDS_TROVE_SSH_PORT" 2 18 10 10000 \
$"Password:" 3 1 "$FRIENDS_TROVE_PASSWORD" 3 18 40 10000 \
--title $"Main Repository (Mirrors)" \
--form $"If you do not wish to use the default repositories they can be obtained from mirrored repos on another ${PROJECT_NAME} system.\n\nThe repositories are for applications which are not yet packaged for Debian.\n\nTo use the defaults just select Ok." 18 65 4 \
$"URL:" 1 1 "$FRIENDS_MIRRORS_SERVER" 1 18 40 18 \
$"SSH Port:" 2 1 "$FRIENDS_MIRRORS_SSH_PORT" 2 18 10 10000 \
$"Password:" 3 1 "$FRIENDS_MIRRORS_PASSWORD" 3 18 40 10000 \
2> $data
sel=$?
case $sel in
1) return;;
255) return;;
esac
new_trove_url=$(cat $data | sed -n 1p)
new_trove_ssh_port=$(cat $data | sed -n 2p)
new_trove_password=$(cat $data | sed -n 3p)
new_mirrors_url=$(cat $data | sed -n 1p)
new_mirrors_ssh_port=$(cat $data | sed -n 2p)
new_mirrors_password=$(cat $data | sed -n 3p)
if [ ${#new_trove_url} -lt 2 ]; then
if [ ${#new_mirrors_url} -lt 2 ]; then
return
fi
if [ ${#new_trove_ssh_port} -lt 1 ]; then
if [ ${#new_mirrors_ssh_port} -lt 1 ]; then
return
fi
if [ ${#new_trove_password} -lt 10 ]; then
if [ ${#new_mirrors_password} -lt 10 ]; then
dialog --title $"Main Repository" \
--msgbox $'Trove password was too short. Should be at least 10 characters.' 6 40
--msgbox $'Mirrors password was too short. Should be at least 10 characters.' 6 40
return
fi
if [[ $new_trove_url == *"."* ]]; then
FRIENDS_TROVE_SERVER=$new_trove_url
FRIENDS_TROVE_SSH_PORT=$new_trove_ssh_port
FRIENDS_TROVE_PASSWORD=$new_trove_password
if [[ $new_mirrors_url == *"."* ]]; then
FRIENDS_MIRRORS_SERVER=$new_mirrors_url
FRIENDS_MIRRORS_SSH_PORT=$new_mirrors_ssh_port
FRIENDS_MIRRORS_PASSWORD=$new_mirrors_password
dialog --title $"Main Repository" \
--msgbox $"Main repository set to $FRIENDS_TROVE_SERVER" 6 60
--msgbox $"Main repository set to $FRIENDS_MIRRORS_SERVER" 6 60
fi
}
@ -1754,14 +1754,14 @@ function read_configuration {
fi
if [ -f $CONFIGURATION_FILE ]; then
if grep -q "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE; then
FRIENDS_TROVE_SERVER=$(grep "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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_TROVE_SSH_PORT" $CONFIGURATION_FILE; then
FRIENDS_TROVE_SSH_PORT=$(grep "FRIENDS_TROVE_SSH_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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
if grep -q "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE; then
FRIENDS_TROVE_PASSWORD=$(grep "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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 "ENABLE_SOCIAL_KEY_MANAGEMENT" $CONFIGURATION_FILE; then
ENABLE_SOCIAL_KEY_MANAGEMENT=$(grep "ENABLE_SOCIAL_KEY_MANAGEMENT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')

View File

@ -64,11 +64,11 @@ if [ -f $CONFIGURATION_FILE ]; then
fi
fi
# Trove settings
FRIENDS_TROVE_SERVER=
FRIENDS_TROVE_SSH_PORT=2222
FRIENDS_TROVE_PASSWORD=
MY_TROVE_PASSWORD=
# Mirrors settings
FRIENDS_MIRRORS_SERVER=
FRIENDS_MIRRORS_SSH_PORT=2222
FRIENDS_MIRRORS_PASSWORD=
MY_MIRRORS_PASSWORD=
function any_key {
echo ' '
@ -89,24 +89,24 @@ function check_for_updates {
function read_repo_servers {
if [ -f $CONFIGURATION_FILE ]; then
if grep -q "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE; then
FRIENDS_TROVE_SERVER=$(grep "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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_TROVE_SSH_PORT" $CONFIGURATION_FILE; then
FRIENDS_TROVE_SSH_PORT=$(grep "FRIENDS_TROVE_SSH_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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
if grep -q "MY_TROVE_PASSWORD" $CONFIGURATION_FILE; then
MY_TROVE_PASSWORD=$(grep "MY_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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_TROVE_PASSWORD" $CONFIGURATION_FILE; then
FRIENDS_TROVE_PASSWORD=$(grep "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
if grep -q "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
FRIENDS_MIRRORS_PASSWORD=$(grep "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
fi
if [ ! $FRIENDS_TROVE_SERVER ]; then
if [ ! $FRIENDS_MIRRORS_SERVER ]; then
return
fi
if [ ${#FRIENDS_TROVE_SERVER} -lt 2 ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -lt 2 ]; then
return
fi
@ -120,8 +120,8 @@ function read_repo_servers {
for line in "${REPOS[@]}"
do
repo_name=$(echo "$line" | awk -F '=' '{print $1}')
trove_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
friends_repo_url="ssh://trove@${FRIENDS_TROVE_SERVER}:${FRIENDS_TROVE_SSH_PORT}/home/trove/${trove_name}"
mirrors_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
friends_repo_url="ssh://mirrors@${FRIENDS_MIRRORS_SERVER}:${FRIENDS_MIRRORS_SSH_PORT}/home/mirrors/${mirrors_name}"
${repo_name}="${friends_repo_url}"
done
}
@ -130,61 +130,61 @@ function set_main_repo {
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --backtitle $"Freedombone Control Panel" \
--title $"Main Repository (Trove)" \
--form $"If you do not wish to use the default repositories they can be obtained from another ${PROJECT_NAME} server acting as a trove.\n\nA trove is just a mirrored collection of git repositories." 14 60 3 \
$"URL:" 1 1 "$FRIENDS_TROVE_SERVER" 1 14 40 15 \
$"SSH Port:" 2 1 "$FRIENDS_TROVE_SSH_PORT" 2 14 40 10000 \
$"Password:" 3 1 "$FRIENDS_TROVE_PASSWORD" 3 14 40 10000 \
--title $"Main Repository (Mirrors)" \
--form $"If you do not wish to use the default repositories they can be obtained from mirrors on another ${PROJECT_NAME} server." 14 60 3 \
$"URL:" 1 1 "$FRIENDS_MIRRORS_SERVER" 1 14 40 15 \
$"SSH Port:" 2 1 "$FRIENDS_MIRRORS_SSH_PORT" 2 14 40 10000 \
$"Password:" 3 1 "$FRIENDS_MIRRORS_PASSWORD" 3 14 40 10000 \
2> $data
sel=$?
case $sel in
1) return;;
255) return;;
esac
new_trove_url=$(cat $data | sed -n 1p)
new_trove_ssh_port=$(cat $data | sed -n 2p)
new_trove_password=$(cat $data | sed -n 3p)
new_mirrors_url=$(cat $data | sed -n 1p)
new_mirrors_ssh_port=$(cat $data | sed -n 2p)
new_mirrors_password=$(cat $data | sed -n 3p)
if [ ${#new_trove_url} -lt 2 ]; then
if [ ${#new_mirrors_url} -lt 2 ]; then
return
fi
if [ ${#new_trove_ssh_port} -lt 1 ]; then
if [ ${#new_mirrors_ssh_port} -lt 1 ]; then
return
fi
if [ ${#new_trove_password} -lt 10 ]; then
if [ ${#new_mirrors_password} -lt 10 ]; then
dialog --title $"Main Repository" \
--msgbox $'Trove password was too short. Should be at least 10 characters.' 6 40
--msgbox $'Mirrors password was too short. Should be at least 10 characters.' 6 40
return
fi
if [[ $new_trove_url == *"."* ]]; then
FRIENDS_TROVE_SERVER=$new_trove_url
FRIENDS_TROVE_SSH_PORT=$new_trove_ssh_port
FRIENDS_TROVE_PASSWORD=$new_trove_password
if [[ $new_mirrors_url == *"."* ]]; then
FRIENDS_MIRRORS_SERVER=$new_mirrors_url
FRIENDS_MIRRORS_SSH_PORT=$new_mirrors_ssh_port
FRIENDS_MIRRORS_PASSWORD=$new_mirrors_password
if ! grep -q "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE; then
echo "FRIENDS_TROVE_SERVER=$FRIENDS_TROVE_SERVER" >> $CONFIGURATION_FILE
if ! grep -q "FRIENDS_MIRRORS_SERVER" $CONFIGURATION_FILE; then
echo "FRIENDS_MIRRORS_SERVER=$FRIENDS_MIRRORS_SERVER" >> $CONFIGURATION_FILE
else
sed -i "s|FRIENDS_TROVE_SERVER=.*|FRIENDS_TROVE_SERVER=$FRIENDS_TROVE_SERVER|g" $CONFIGURATION_FILE
sed -i "s|FRIENDS_MIRRORS_SERVER=.*|FRIENDS_MIRRORS_SERVER=$FRIENDS_MIRRORS_SERVER|g" $CONFIGURATION_FILE
fi
if ! grep -q "FRIENDS_TROVE_SSH_PORT" $CONFIGURATION_FILE; then
echo "FRIENDS_TROVE_SSH_PORT=$FRIENDS_TROVE_SSH_PORT" >> $CONFIGURATION_FILE
if ! grep -q "FRIENDS_MIRRORS_SSH_PORT" $CONFIGURATION_FILE; then
echo "FRIENDS_MIRRORS_SSH_PORT=$FRIENDS_MIRRORS_SSH_PORT" >> $CONFIGURATION_FILE
else
sed -i "s|FRIENDS_TROVE_SSH_PORT=.*|FRIENDS_TROVE_SSH_PORT=$FRIENDS_TROVE_SSH_PORT|g" $CONFIGURATION_FILE
sed -i "s|FRIENDS_MIRRORS_SSH_PORT=.*|FRIENDS_MIRRORS_SSH_PORT=$FRIENDS_MIRRORS_SSH_PORT|g" $CONFIGURATION_FILE
fi
if ! grep -q "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE; then
echo "FRIENDS_TROVE_PASSWORD=$FRIENDS_TROVE_PASSWORD" >> $CONFIGURATION_FILE
if ! grep -q "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
echo "FRIENDS_MIRRORS_PASSWORD=$FRIENDS_MIRRORS_PASSWORD" >> $CONFIGURATION_FILE
else
sed -i "s|FRIENDS_TROVE_PASSWORD=.*|FRIENDS_TROVE_PASSWORD=$FRIENDS_TROVE_PASSWORD|g" $CONFIGURATION_FILE
sed -i "s|FRIENDS_MIRRORS_PASSWORD=.*|FRIENDS_MIRRORS_PASSWORD=$FRIENDS_MIRRORS_PASSWORD|g" $CONFIGURATION_FILE
fi
# re-read the repos
read_repo_servers
dialog --title $"Main Repository" \
--msgbox $"Main repository set to $FRIENDS_TROVE_SERVER" 6 60
--msgbox $"Main repository set to $FRIENDS_MIRRORS_SERVER" 6 60
fi
}
@ -349,7 +349,7 @@ function show_users {
echo '--------------------------------------------------------------------------'
for d in /home/*/ ; do
USRNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USRNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USRNAME != "git" && $USRNAME != "mirrors" ]]; then
echo -n -e "$(pad_string ${USRNAME})"
# get the SIP extension
SIPEXT=
@ -376,27 +376,27 @@ function show_users {
echo ''
}
function show_trove_password {
if [ ! /home/trove ]; then
function show_mirrors_password {
if [ ! /home/mirrors ]; then
return
fi
if grep -q "MY_TROVE_PASSWORD" $CONFIGURATION_FILE; then
MY_TROVE_PASSWORD=$(grep "MY_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
if grep -q "MY_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
MY_MIRRORS_PASSWORD=$(grep "MY_MIRRORS_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
echo 'Local Trove'
echo 'Local Mirrors'
echo '==========='
echo ''
echo -n "URL: "
echo "$(cat ${COMPLETION_FILE} | grep 'ssh onion domain' | awk -F ':' '{print $2}')"
echo "SSH Port: $SSH_PORT"
echo "Password: $MY_TROVE_PASSWORD"
echo "Password: $MY_MIRRORS_PASSWORD"
echo ''
}
function show_about {
clear
show_domains
show_trove_password
show_mirrors_password
show_users
any_key
}
@ -1516,7 +1516,7 @@ function menu_top_level {
6 $"Manage Users" off \
7 $"Email Filtering Rules" off \
8 $"Security Settings" off \
9 $"Set the main repository (Trove)" off \
9 $"Set the main repository (repo mirrors)" off \
10 $"Hubzilla" off \
11 $"Media menu" off \
12 $"IRC menu" off \

245
src/freedombone-mirrors Executable file
View File

@ -0,0 +1,245 @@
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# Mirror git repos which the project depends on
#
# License
# =======
#
# Copyright (C) 2015-2016 Bob Mottram <bob@robotics.uk.to>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
PROJECT_NAME='freedombone'
export TEXTDOMAIN=${PROJECT_NAME}-mirrors
export TEXTDOMAINDIR="/usr/share/locale"
# Minimum number of characters in a password
MINIMUM_PASSWORD_LENGTH=10
CONFIGURATION_FILE="/root/${PROJECT_NAME}.cfg"
# if this is blank then just use the default repos
FRIENDS_MIRRORS_SERVER=
REPOS=
MIRRORS_BASE=/home/mirrors/mirrors
MY_MIRRORS_PASSWORD=
FRIENDS_MIRRORS_PASSWORD=
NEW_MIRRORS='no'
FRIENDS_MIRRORS_SSH_PORT=2222
MAIN_COMMAND=/usr/local/bin/${PROJECT_NAME}
if [ ! -f $MAIN_COMMAND ]; then
MAIN_COMMAND=/usr/bin/${PROJECT_NAME}
fi
REPOS=($(cat ${MAIN_COMMAND} | grep "_REPO=\"" | uniq -u | sed 's|${PROJECT_NAME}|'"${PROJECT_NAME}"'|g'))
# 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
function show_help {
echo ''
echo $"${PROJECT_NAME}-mirrors --sync [domain/url] -p [password]"
echo ''
echo $'Creates or syncs with a set of git repositories'
echo ''
echo $' --help Show help'
echo $' -n|--new [yes|no] Start a new mirrors'
echo $" -p|--password [yes|no] Friend's mirrors user password"
echo $" -m|--mypassword [yes|no] Local mirrors user password"
echo $" --port [number] Friend's server ssh port number"
echo $" -s|--sync [domain] Friend's server domain to sync with"
echo ''
exit 0
}
function create_mirrors_user {
if [ -d /home/mirrors ]; then
return
fi
create_password='no'
if [ ! "$MY_MIRRORS_PASSWORD" ]; then
create_password='yes'
fi
if [ ${#MY_MIRRORS_PASSWORD} -lt ${MINIMUM_PASSWORD_LENGTH} ]; then
echo $'Password is too short. Creating new one.'
create_password='yes'
fi
if [[ $create_password == 'yes' ]]; then
MY_MIRRORS_PASSWORD="$(openssl rand -base64 20 | cut -c1-18)"
fi
useradd -m -p "$MY_MIRRORS_PASSWORD" -s /bin/bash mirrors
# remove any existing user files
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
}
function enable_mirrors_via_onion {
if ! grep -q 'Host *.onion' /home/mirrors/.ssh/config; then
if [ ! -d /home/mirrors/.ssh ]; then
mkdir /home/mirrors/.ssh
fi
echo 'Host *.onion' >> /home/mirrors/.ssh/config
echo 'ProxyCommand connect -R remote -5 -S 127.0.0.1:9050 %h %p' >> /home/mirrors/.ssh/config
chown mirrors:mirrors /home/mirrors/.ssh
chown mirrors:mirrors /home/mirrors/.ssh/config
fi
}
function update_repos_from_friend {
if [ ! $FRIENDS_MIRRORS_SERVER ]; then
return
fi
if [ ${#FRIENDS_MIRRORS_SERVER} -lt 2 ]; then
return
fi
new_repos=()
for line in "${REPOS[@]}"
do
repo_name=$(echo "$line" | awk -F '=' '{print $1}')
mirrors_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
#repo_url=$(echo "$line" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}')
friends_repo_url="ssh://mirrors@${FRIENDS_MIRRORS_SERVER}:${FRIENDS_MIRRORS_SSH_PORT}/home/mirrors/${mirrors_name}"
new_line="${repo_name}=\"${friends_repo_url}\""
new_repos+=($new_line)
done
REPOS=("${new_repos[@]}")
}
function sync_mirrors_repos {
for line in "${REPOS[@]}"
do
repo_name=$(echo "$line" | awk -F '=' '{print $1}')
repo_url=$(echo "$line" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}')
mirrors_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
if [[ ${mirrors_name} != 'debian' ]]; then
if [[ $NEW_MIRRORS == 'yes' ]]; then
if [ -d /home/mirrors/${mirrors_name} ]; then
rm -rf /home/mirrors/${mirrors_name}
fi
fi
if [ ! -d /home/mirrors/${mirrors_name} ]; then
if [[ ${repo_url} != 'ssh:'* ]]; then
git clone --mirror ${repo_url} /home/mirrors/${mirrors_name}
else
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git clone --mirror ${repo_url} /home/mirrors/${mirrors_name}
fi
if [ ! -d /home/mirrors/${mirrors_name} ]; then
echo $"WARNING: failed to mirror repo ${repo_url}"
fi
else
cd /home/mirrors/${mirrors_name}
git remote set-url origin ${repo_url}
if [[ ${repo_url} != 'ssh:'* ]]; then
git fetch -p origin
else
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git fetch -p origin
fi
fi
fi
done
chown -R mirrors:mirrors /home/mirrors
}
while [[ $# > 1 ]]
do
key="$1"
case $key in
--help)
show_help
;;
-s|--sync)
shift
# use repos on another server
FRIENDS_MIRRORS_SERVER="$1"
;;
-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
;;
-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
;;
-n|--new)
shift
NEW_MIRRORS="$1"
;;
--port)
shift
FRIENDS_MIRRORS_SSH_PORT=${1}
;;
*)
# unknown option
;;
esac
shift
done
create_mirrors_user
enable_mirrors_via_onion
update_repos_from_friend
sync_mirrors_repos
exit 0

View File

@ -116,7 +116,7 @@ function unmount_drive {
echo $"Setting permissions"
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
chown -R $USERNAME:$USERNAME /home/$USERNAME
fi
done
@ -356,7 +356,7 @@ function restore_mutt_settings {
if [ -d $USB_MOUNT/backup/mutt ]; then
for d in $USB_MOUNT/backup/mutt/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
fi
@ -388,7 +388,7 @@ function restore_gpg {
if [ -d $USB_MOUNT/backup/gnupg ]; then
for d in $USB_MOUNT/backup/gnupg/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
fi
@ -422,7 +422,7 @@ function restore_procmail {
if [ -d $USB_MOUNT/backup/procmail ]; then
for d in $USB_MOUNT/backup/procmail/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
fi
@ -449,7 +449,7 @@ function restore_spamassassin {
if [ -d $USB_MOUNT/backup/spamassassin ]; then
for d in $USB_MOUNT/backup/spamassassin/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d $USB_MOUNT/backup/spamassassin/$USERNAME ]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
@ -525,7 +525,7 @@ function restore_user_ssh_keys {
if [ -d $USB_MOUNT/backup/ssh ]; then
for d in $USB_MOUNT/backup/ssh/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
fi
@ -552,7 +552,7 @@ function restore_user_config {
if [ -d $USB_MOUNT/backup/config ]; then
for d in $USB_MOUNT/backup/config/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
fi
@ -622,7 +622,7 @@ function restore_personal_settings {
if [ -d $USB_MOUNT/backup/personal ]; then
for d in $USB_MOUNT/backup/personal/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d $USB_MOUNT/backup/personal/$USERNAME ]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
@ -739,7 +739,7 @@ function restore_owncloud {
chown -R www-data:www-data /var/lib/owncloud/assets
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
occ files:scan $USERNAME
fi
done
@ -853,7 +853,7 @@ function restore_blog {
fi
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post ]; then
mv /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/*.md /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post
fi
@ -894,7 +894,7 @@ function restore_email {
if [ -d $USB_MOUNT/backup/mail ]; then
for d in $USB_MOUNT/backup/mail/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
fi

View File

@ -260,7 +260,7 @@ function restore_mutt_settings {
fi
for d in $SERVER_DIRECTORY/backup/mutt/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d $SERVER_DIRECTORY/backup/mutt/$USERNAME ]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
@ -291,7 +291,7 @@ function restore_gpg {
fi
for d in $SERVER_DIRECTORY/backup/gnupg/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d $SERVER_DIRECTORY/backup/gnupg/$USERNAME ]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
@ -323,7 +323,7 @@ function restore_procmail {
fi
for d in $SERVER_DIRECTORY/backup/procmail/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d $SERVER_DIRECTORY/backup/procmail/$USERNAME ]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
@ -349,7 +349,7 @@ function restore_spamassassin {
fi
for d in $SERVER_DIRECTORY/backup/spamassassin/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d $SERVER_DIRECTORY/backup/spamassassin/$USERNAME ]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
@ -411,7 +411,7 @@ function restore_ssh_keys {
fi
for d in $SERVER_DIRECTORY/backup/ssh/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d $SERVER_DIRECTORY/backup/ssh/$USERNAME ]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
@ -437,7 +437,7 @@ function restore_user_config {
fi
for d in $SERVER_DIRECTORY/backup/config/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d $SERVER_DIRECTORY/backup/config/$USERNAME ]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
@ -504,7 +504,7 @@ function restore_personal_settings {
fi
for d in $SERVER_DIRECTORY/backup/personal/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d $SERVER_DIRECTORY/backup/personal/$USERNAME ]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME
@ -624,7 +624,7 @@ function restore_owncloud {
chown -R www-data:www-data /var/lib/owncloud/assets
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
occ files:scan $USERNAME
fi
done
@ -733,7 +733,7 @@ function restore_blog {
fi
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post ]; then
mv /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/*.md /var/www/${FULLBLOG_DOMAIN_NAME}/htdocs/content/$USERNAME/blog/uncategorized/post
fi
@ -825,7 +825,7 @@ function restore_email {
fi
for d in $SERVER_DIRECTORY/backup/mail/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $6}')
if [[ $USERNAME != "git" && $USRNAME != "trove" ]]; then
if [[ $USERNAME != "git" && $USRNAME != "mirrors" ]]; then
if [ -d $SERVER_DIRECTORY/backup/mail/$USERNAME ]; then
if [ ! -d /home/$USERNAME ]; then
${PROJECT_NAME}-adduser $USERNAME

View File

@ -1,245 +0,0 @@
#!/bin/bash
#
# .---. . .
# | | |
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
#
# Freedom in the Cloud
#
# Mirror git repos which the project depends on
#
# License
# =======
#
# Copyright (C) 2015-2016 Bob Mottram <bob@robotics.uk.to>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
PROJECT_NAME='freedombone'
export TEXTDOMAIN=${PROJECT_NAME}-trove
export TEXTDOMAINDIR="/usr/share/locale"
# Minimum number of characters in a password
MINIMUM_PASSWORD_LENGTH=10
CONFIGURATION_FILE="/root/${PROJECT_NAME}.cfg"
# if this is blank then just use the default repos
FRIENDS_TROVE_SERVER=
REPOS=
TROVE_BASE=/home/trove/trove
MY_TROVE_PASSWORD=
FRIENDS_TROVE_PASSWORD=
NEW_TROVE='no'
FRIENDS_TROVE_SSH_PORT=2222
MAIN_COMMAND=/usr/local/bin/${PROJECT_NAME}
if [ ! -f $MAIN_COMMAND ]; then
MAIN_COMMAND=/usr/bin/${PROJECT_NAME}
fi
REPOS=($(cat ${MAIN_COMMAND} | grep "_REPO=\"" | uniq -u | sed 's|${PROJECT_NAME}|'"${PROJECT_NAME}"'|g'))
# obtain the trove password if it exists
if [ -f $CONFIGURATION_FILE ]; then
if ! grep -q "MY_TROVE_PASSWORD" $CONFIGURATION_FILE; then
MY_TROVE_PASSWORD=$(grep "MY_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if ! grep -q "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE; then
FRIENDS_TROVE_SERVER=$(grep "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if ! grep -q "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE; then
FRIENDS_TROVE_PASSWORD=$(grep "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
if ! grep -q "FRIENDS_TROVE_SSH_PORT" $CONFIGURATION_FILE; then
FRIENDS_TROVE_SSH_PORT=$(grep "FRIENDS_TROVE_SSH_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
fi
function show_help {
echo ''
echo $"${PROJECT_NAME}-trove --sync [domain/url] -p [password]"
echo ''
echo $'Creates or syncs with a set of git repositories'
echo ''
echo $' --help Show help'
echo $' -n|--new [yes|no] Start a new trove'
echo $" -p|--password [yes|no] Friend's trove user password"
echo $" -m|--mypassword [yes|no] Local trove user password"
echo $" --port [number] Friend's server ssh port number"
echo $" -s|--sync [domain] Friend's server domain to sync with"
echo ''
exit 0
}
function create_trove_user {
if [ -d /home/trove ]; then
return
fi
create_password='no'
if [ ! "$MY_TROVE_PASSWORD" ]; then
create_password='yes'
fi
if [ ${#MY_TROVE_PASSWORD} -lt ${MINIMUM_PASSWORD_LENGTH} ]; then
echo $'Password is too short. Creating new one.'
create_password='yes'
fi
if [[ $create_password == 'yes' ]]; then
MY_TROVE_PASSWORD="$(openssl rand -base64 20 | cut -c1-18)"
fi
useradd -m -p "$MY_TROVE_PASSWORD" -s /bin/bash trove
# remove any existing user files
rm -rf /home/trove/*
# store the trove password
if [ -f $CONFIGURATION_FILE ]; then
if ! grep -q "MY_TROVE_PASSWORD" $CONFIGURATION_FILE; then
echo "MY_TROVE_PASSWORD=$MY_TROVE_PASSWORD" >> $CONFIGURATION_FILE
else
sed -i "s|MY_TROVE_PASSWORD=.*|MY_TROVE_PASSWORD=${MY_TROVE_PASSWORD}|g" $CONFIGURATION_FILE
fi
fi
}
function enable_trove_via_onion {
if ! grep -q 'Host *.onion' /home/trove/.ssh/config; then
if [ ! -d /home/trove/.ssh ]; then
mkdir /home/trove/.ssh
fi
echo 'Host *.onion' >> /home/trove/.ssh/config
echo 'ProxyCommand connect -R remote -5 -S 127.0.0.1:9050 %h %p' >> /home/trove/.ssh/config
chown trove:trove /home/trove/.ssh
chown trove:trove /home/trove/.ssh/config
fi
}
function update_repos_from_friend {
if [ ! $FRIENDS_TROVE_SERVER ]; then
return
fi
if [ ${#FRIENDS_TROVE_SERVER} -lt 2 ]; then
return
fi
new_repos=()
for line in "${REPOS[@]}"
do
repo_name=$(echo "$line" | awk -F '=' '{print $1}')
trove_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
#repo_url=$(echo "$line" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}')
friends_repo_url="ssh://trove@${FRIENDS_TROVE_SERVER}:${FRIENDS_TROVE_SSH_PORT}/home/trove/${trove_name}"
new_line="${repo_name}=\"${friends_repo_url}\""
new_repos+=($new_line)
done
REPOS=("${new_repos[@]}")
}
function sync_trove_repos {
for line in "${REPOS[@]}"
do
repo_name=$(echo "$line" | awk -F '=' '{print $1}')
repo_url=$(echo "$line" | awk -F '=' '{print $2}' | awk -F '"' '{print $2}')
trove_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
if [[ ${trove_name} != 'debian' ]]; then
if [[ $NEW_TROVE == 'yes' ]]; then
if [ -d /home/trove/${trove_name} ]; then
rm -rf /home/trove/${trove_name}
fi
fi
if [ ! -d /home/trove/${trove_name} ]; then
if [[ ${repo_url} != 'ssh:'* ]]; then
git clone --mirror ${repo_url} /home/trove/${trove_name}
else
sshpass -p "$FRIENDS_TROVE_PASSWORD" git clone --mirror ${repo_url} /home/trove/${trove_name}
fi
if [ ! -d /home/trove/${trove_name} ]; then
echo $"WARNING: failed to mirror repo ${repo_url}"
fi
else
cd /home/trove/${trove_name}
git remote set-url origin ${repo_url}
if [[ ${repo_url} != 'ssh:'* ]]; then
git fetch -p origin
else
sshpass -p "$FRIENDS_TROVE_PASSWORD" git fetch -p origin
fi
fi
fi
done
chown -R trove:trove /home/trove
}
while [[ $# > 1 ]]
do
key="$1"
case $key in
--help)
show_help
;;
-s|--sync)
shift
# use repos on another server
FRIENDS_TROVE_SERVER="$1"
;;
-m|--mypass|--mypassword)
shift
MY_TROVE_PASSWORD="$1"
if [ -f $CONFIGURATION_FILE ]; then
if ! grep -q "MY_TROVE_PASSWORD" $CONFIGURATION_FILE; then
echo "MY_TROVE_PASSWORD=$MY_TROVE_PASSWORD" >> $CONFIGURATION_FILE
else
sed -i "s|MY_TROVE_PASSWORD=.*|MY_TROVE_PASSWORD=${MY_TROVE_PASSWORD}|g" $CONFIGURATION_FILE
fi
fi
;;
-p|--pass|--password)
shift
FRIENDS_TROVE_PASSWORD="$1"
if [ -f $CONFIGURATION_FILE ]; then
if ! grep -q "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE; then
echo "FRIENDS_TROVE_PASSWORD=$FRIENDS_TROVE_PASSWORD" >> $CONFIGURATION_FILE
else
sed -i "s|FRIENDS_TROVE_PASSWORD=.*|FRIENDS_TROVE_PASSWORD=${FRIENDS_TROVE_PASSWORD}|g" $CONFIGURATION_FILE
fi
fi
;;
-n|--new)
shift
NEW_TROVE="$1"
;;
--port)
shift
FRIENDS_TROVE_SSH_PORT=${1}
;;
*)
# unknown option
;;
esac
shift
done
create_trove_user
enable_trove_via_onion
update_repos_from_friend
sync_trove_repos
exit 0

View File

@ -37,31 +37,31 @@ CONFIGURATION_FILE="/root/${PROJECT_NAME}.cfg"
PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"
FRIENDS_TROVE_SERVER=
FRIENDS_TROVE_SSH_PORT=
FRIENDS_TROVE_PASSWORD=
MY_TROVE_PASSWORD=
FRIENDS_MIRRORS_SERVER=
FRIENDS_MIRRORS_SSH_PORT=
FRIENDS_MIRRORS_PASSWORD=
MY_MIRRORS_PASSWORD=
function read_repo_servers {
if [ -f $CONFIGURATION_FILE ]; then
if grep -q "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE; then
FRIENDS_TROVE_SERVER=$(grep "FRIENDS_TROVE_SERVER" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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_TROVE_SSH_PORT" $CONFIGURATION_FILE; then
FRIENDS_TROVE_SSH_PORT=$(grep "FRIENDS_TROVE_SSH_PORT" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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
if grep -q "MY_TROVE_PASSWORD" $CONFIGURATION_FILE; then
MY_TROVE_PASSWORD=$(grep "MY_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
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_TROVE_PASSWORD" $CONFIGURATION_FILE; then
FRIENDS_TROVE_PASSWORD=$(grep "FRIENDS_TROVE_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
if grep -q "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE; then
FRIENDS_MIRRORS_PASSWORD=$(grep "FRIENDS_MIRRORS_PASSWORD" $CONFIGURATION_FILE | awk -F '=' '{print $2}')
fi
fi
if [ ! $FRIENDS_TROVE_SERVER ]; then
if [ ! $FRIENDS_MIRRORS_SERVER ]; then
return
fi
if [ ${#FRIENDS_TROVE_SERVER} -lt 2 ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -lt 2 ]; then
return
fi
@ -75,8 +75,8 @@ function read_repo_servers {
for line in "${REPOS[@]}"
do
repo_name=$(echo "$line" | awk -F '=' '{print $1}')
trove_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
friends_repo_url="ssh://trove@${FRIENDS_TROVE_SERVER}:${FRIENDS_TROVE_SSH_PORT}/home/trove/${trove_name}"
mirrors_name=$(echo "$repo_name" | sed "s|_REPO||g" | awk '{print tolower($0)}')
friends_repo_url="ssh://mirrors@${FRIENDS_MIRRORS_SERVER}:${FRIENDS_MIRRORS_SSH_PORT}/home/mirrors/${mirrors_name}"
${repo_name}="${friends_repo_url}"
done
}
@ -85,11 +85,11 @@ function git_clone {
repo_url="$1"
destination_dir="$2"
if [[ "$repo_url" == "ssh:"* ]]; then
if [ "${FRIENDS_TROVE_SERVER}" ]; then
if [ ${#FRIENDS_TROVE_SERVER} -gt 2 ]; then
if [ "$FRIENDS_TROVE_PASSWORD" ]; then
if [ ${#FRIENDS_TROVE_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_TROVE_PASSWORD" git clone "$repo_url" "$destination_dir"
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git clone "$repo_url" "$destination_dir"
return
fi
fi
@ -107,11 +107,11 @@ function git_pull {
git stash
git remote set-url origin $1
git checkout master
if [ "${FRIENDS_TROVE_SERVER}" ]; then
if [ ${#FRIENDS_TROVE_SERVER} -gt 2 ]; then
if [ "$FRIENDS_TROVE_PASSWORD" ]; then
if [ ${#FRIENDS_TROVE_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_TROVE_PASSWORD" git pull
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git pull
if [ $2 ]; then
git checkout $2 -b $2
fi