Deprecate mirrors
This commit is contained in:
parent
28381df8f5
commit
9aebefe0aa
|
@ -59,10 +59,6 @@ DH_KEYLENGTH=2048
|
||||||
INSTALL_DIR=/root/build
|
INSTALL_DIR=/root/build
|
||||||
LETSENCRYPT_SERVER='https://acme-v01.api.letsencrypt.org/directory'
|
LETSENCRYPT_SERVER='https://acme-v01.api.letsencrypt.org/directory'
|
||||||
MY_EMAIL_ADDRESS=
|
MY_EMAIL_ADDRESS=
|
||||||
FRIENDS_MIRRORS_SERVER=
|
|
||||||
FRIENDS_MIRRORS_PASSWORD=
|
|
||||||
FRIENDS_MIRRORS_SSH_PORT=
|
|
||||||
MY_MIRRORS_PASSWORD=
|
|
||||||
|
|
||||||
function show_help {
|
function show_help {
|
||||||
echo ''
|
echo ''
|
||||||
|
@ -360,7 +356,6 @@ function create_cert {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
read_repo_servers
|
|
||||||
create_cert
|
create_cert
|
||||||
generate_dh_params
|
generate_dh_params
|
||||||
restart_web_server
|
restart_web_server
|
||||||
|
|
|
@ -1159,7 +1159,7 @@ function spam_filtering {
|
||||||
echo '#!/bin/bash' > /usr/bin/filterspam
|
echo '#!/bin/bash' > /usr/bin/filterspam
|
||||||
echo 'for d in /home/*/ ; do' >> /usr/bin/filterspam
|
echo 'for d in /home/*/ ; do' >> /usr/bin/filterspam
|
||||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/filterspam
|
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/filterspam
|
||||||
echo ' if [[ $USERNAME != "git" && $USERNAME != "go" && $USERNAME != "gogs" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then' >> /usr/bin/filterspam
|
echo ' if [[ $USERNAME != "git" && $USERNAME != "go" && $USERNAME != "gogs" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then' >> /usr/bin/filterspam
|
||||||
echo ' MAILDIR=/home/$USERNAME/Maildir/.learn-spam' >> /usr/bin/filterspam
|
echo ' MAILDIR=/home/$USERNAME/Maildir/.learn-spam' >> /usr/bin/filterspam
|
||||||
echo ' if [ ! -d "$MAILDIR" ]; then' >> /usr/bin/filterspam
|
echo ' if [ ! -d "$MAILDIR" ]; then' >> /usr/bin/filterspam
|
||||||
echo ' exit' >> /usr/bin/filterspam
|
echo ' exit' >> /usr/bin/filterspam
|
||||||
|
@ -1181,7 +1181,7 @@ function spam_filtering {
|
||||||
echo '#!/bin/bash' > /usr/bin/filterham
|
echo '#!/bin/bash' > /usr/bin/filterham
|
||||||
echo 'for d in /home/*/ ; do' >> /usr/bin/filterham
|
echo 'for d in /home/*/ ; do' >> /usr/bin/filterham
|
||||||
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/filterham
|
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/filterham
|
||||||
echo ' if [[ $USERNAME != "git" && $USERNAME != "go" && $USERNAME != "gogs" && $USERNAME != "mirrors" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then' >> /usr/bin/filterham
|
echo ' if [[ $USERNAME != "git" && $USERNAME != "go" && $USERNAME != "gogs" && $USERNAME != "sync" && $USERNAME != "tahoelafs" ]]; then' >> /usr/bin/filterham
|
||||||
echo ' MAILDIR=/home/$USERNAME/Maildir/.learn-ham' >> /usr/bin/filterham
|
echo ' MAILDIR=/home/$USERNAME/Maildir/.learn-ham' >> /usr/bin/filterham
|
||||||
echo ' if [ ! -d "$MAILDIR" ]; then' >> /usr/bin/filterham
|
echo ' if [ ! -d "$MAILDIR" ]; then' >> /usr/bin/filterham
|
||||||
echo ' exit' >> /usr/bin/filterham
|
echo ' exit' >> /usr/bin/filterham
|
||||||
|
|
|
@ -97,12 +97,6 @@ ONION_ONLY="no"
|
||||||
SELECTED_USERNAME=
|
SELECTED_USERNAME=
|
||||||
SOCIALINSTANCE=
|
SOCIALINSTANCE=
|
||||||
|
|
||||||
# Mirrors settings
|
|
||||||
FRIENDS_MIRRORS_SERVER=
|
|
||||||
FRIENDS_MIRRORS_SSH_PORT=2222
|
|
||||||
FRIENDS_MIRRORS_PASSWORD=
|
|
||||||
MY_MIRRORS_PASSWORD=
|
|
||||||
|
|
||||||
VALID_CODE=
|
VALID_CODE=
|
||||||
|
|
||||||
PROJECT_INSTALL_DIR=/usr/local/bin
|
PROJECT_INSTALL_DIR=/usr/local/bin
|
||||||
|
@ -861,50 +855,6 @@ do
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
function set_main_repo {
|
|
||||||
return
|
|
||||||
|
|
||||||
data=$(tempfile 2>/dev/null)
|
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
dialog --backtitle $"Freedombone Control Panel" \
|
|
||||||
--title $"Main Repository (Mirrors)" \
|
|
||||||
--form $"If you don't know what this means then just select Ok.\n\nIf you don't 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." 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_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_mirrors_url} -lt 2 ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if [ ${#new_mirrors_ssh_port} -lt 1 ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if [ ${#new_mirrors_password} -lt 10 ]; then
|
|
||||||
dialog --title $"Main Repository" \
|
|
||||||
--msgbox $'Mirrors password was too short. Should be at least 10 characters.' 6 40
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
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_MIRRORS_SERVER" 6 60
|
|
||||||
fi
|
|
||||||
save_configuration_values
|
|
||||||
}
|
|
||||||
|
|
||||||
function interactive_select_language {
|
function interactive_select_language {
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(tempfile 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
trap "rm -f $data" 0 1 2 5 15
|
||||||
|
@ -1074,7 +1024,7 @@ function select_user {
|
||||||
|
|
||||||
users_array=($(ls /home))
|
users_array=($(ls /home))
|
||||||
|
|
||||||
delete=(mirrors git)
|
delete=(git)
|
||||||
for del in ${delete[@]}
|
for del in ${delete[@]}
|
||||||
do
|
do
|
||||||
users_array=(${users_array[@]/$del})
|
users_array=(${users_array[@]/$del})
|
||||||
|
@ -1125,7 +1075,6 @@ function interactive_config {
|
||||||
dialog --title $"Freedombone" --msgbox "$INITIAL_MESSAGE" 15 50
|
dialog --title $"Freedombone" --msgbox "$INITIAL_MESSAGE" 15 50
|
||||||
|
|
||||||
#choose_system_variant
|
#choose_system_variant
|
||||||
#set_main_repo
|
|
||||||
choose_username
|
choose_username
|
||||||
choose_full_name
|
choose_full_name
|
||||||
choose_social_key_management
|
choose_social_key_management
|
||||||
|
|
|
@ -128,12 +128,6 @@ if [[ $USB_DRIVE == *"dev"* ]]; then
|
||||||
USB_DRIVE=$(echo ${USB_DRIVE} | awk -F '/' '{print $3}' | sed 's|1||g' | sed 's|2||g')
|
USB_DRIVE=$(echo ${USB_DRIVE} | awk -F '/' '{print $3}' | sed 's|1||g' | sed 's|2||g')
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Mirrors settings
|
|
||||||
FRIENDS_MIRRORS_SERVER=
|
|
||||||
FRIENDS_MIRRORS_SSH_PORT=2222
|
|
||||||
FRIENDS_MIRRORS_PASSWORD=
|
|
||||||
MY_MIRRORS_PASSWORD=
|
|
||||||
|
|
||||||
function any_key {
|
function any_key {
|
||||||
echo ' '
|
echo ' '
|
||||||
read -n1 -r -p $"Press any key to continue..." key
|
read -n1 -r -p $"Press any key to continue..." key
|
||||||
|
@ -153,7 +147,7 @@ function passwords_select_user {
|
||||||
|
|
||||||
users_array=($(ls /home))
|
users_array=($(ls /home))
|
||||||
|
|
||||||
delete=(mirrors git)
|
delete=(git)
|
||||||
for del in ${delete[@]}
|
for del in ${delete[@]}
|
||||||
do
|
do
|
||||||
users_array=(${users_array[@]/$del})
|
users_array=(${users_array[@]/$del})
|
||||||
|
@ -290,56 +284,6 @@ function check_for_updates {
|
||||||
any_key
|
any_key
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_main_repo {
|
|
||||||
return
|
|
||||||
|
|
||||||
data=$(tempfile 2>/dev/null)
|
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
|
||||||
dialog --backtitle $"Freedombone Control Panel" \
|
|
||||||
--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_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_mirrors_url} -lt 2 ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if [ ${#new_mirrors_ssh_port} -lt 1 ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if [ ${#new_mirrors_password} -lt 10 ]; then
|
|
||||||
dialog --title $"Main Repository" \
|
|
||||||
--msgbox $'Mirrors password was too short. Should be at least 10 characters.' 6 40
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
write_config_param "FRIENDS_MIRRORS_SERVER" "$FRIENDS_MIRRORS_SERVER"
|
|
||||||
write_config_param "FRIENDS_MIRRORS_SSH_PORT" "$FRIENDS_MIRRORS_SSH_PORT"
|
|
||||||
write_config_param "FRIENDS_MIRRORS_PASSWORD" "$FRIENDS_MIRRORS_PASSWORD"
|
|
||||||
|
|
||||||
# re-read the repos
|
|
||||||
read_repo_servers
|
|
||||||
|
|
||||||
dialog --title $"Main Repository" \
|
|
||||||
--msgbox $"Main repository set to $FRIENDS_MIRRORS_SERVER" 6 60
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_user {
|
function add_user {
|
||||||
data=$(tempfile 2>/dev/null)
|
data=$(tempfile 2>/dev/null)
|
||||||
trap "rm -f $data" 0 1 2 5 15
|
trap "rm -f $data" 0 1 2 5 15
|
||||||
|
@ -516,22 +460,6 @@ function show_users {
|
||||||
echo ''
|
echo ''
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_mirrors_password {
|
|
||||||
return
|
|
||||||
|
|
||||||
if [ ! /home/mirrors ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
read_config_param "MY_MIRRORS_PASSWORD"
|
|
||||||
echo 'Local Mirrors'
|
|
||||||
echo '============='
|
|
||||||
echo ''
|
|
||||||
echo -n "URL: "
|
|
||||||
echo "$(cat ${COMPLETION_FILE} | grep 'ssh onion domain' | awk -F ':' '{print $2}') SSH Port: $SSH_PORT"
|
|
||||||
echo "Password: $MY_MIRRORS_PASSWORD"
|
|
||||||
echo ''
|
|
||||||
}
|
|
||||||
|
|
||||||
function show_tahoelafs {
|
function show_tahoelafs {
|
||||||
if [ ! -f /home/tahoelafs/storage/private/storage.furl ]; then
|
if [ ! -f /home/tahoelafs/storage/private/storage.furl ]; then
|
||||||
return
|
return
|
||||||
|
@ -621,7 +549,6 @@ function show_about {
|
||||||
show_ssh_public_key
|
show_ssh_public_key
|
||||||
show_domains
|
show_domains
|
||||||
show_tahoelafs
|
show_tahoelafs
|
||||||
#show_mirrors_password
|
|
||||||
show_users
|
show_users
|
||||||
any_key
|
any_key
|
||||||
}
|
}
|
||||||
|
@ -631,7 +558,7 @@ function select_user {
|
||||||
|
|
||||||
users_array=($(ls /home))
|
users_array=($(ls /home))
|
||||||
|
|
||||||
delete=(mirrors git)
|
delete=(git)
|
||||||
for del in ${delete[@]}
|
for del in ${delete[@]}
|
||||||
do
|
do
|
||||||
users_array=(${users_array[@]/$del})
|
users_array=(${users_array[@]/$del})
|
||||||
|
@ -2180,7 +2107,6 @@ if [ ! -f $COMPLETION_FILE ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ADMIN_USER=$(get_completion_param "Admin user")
|
ADMIN_USER=$(get_completion_param "Admin user")
|
||||||
read_repo_servers
|
|
||||||
menu_top_level
|
menu_top_level
|
||||||
clear
|
clear
|
||||||
cat /etc/motd
|
cat /etc/motd
|
||||||
|
|
|
@ -47,7 +47,6 @@ WIFI_SSID='mesh'
|
||||||
rootdir=''
|
rootdir=''
|
||||||
FN=
|
FN=
|
||||||
CHROOT_PREFIX=''
|
CHROOT_PREFIX=''
|
||||||
FRIENDS_MIRRORS_SERVER=
|
|
||||||
|
|
||||||
# To avoid confusions these are obtained from the main project file
|
# To avoid confusions these are obtained from the main project file
|
||||||
TOXID_REPO=
|
TOXID_REPO=
|
||||||
|
@ -273,10 +272,6 @@ do
|
||||||
shift
|
shift
|
||||||
WIFI_INTERFACE="$1"
|
WIFI_INTERFACE="$1"
|
||||||
;;
|
;;
|
||||||
-m|--mirror)
|
|
||||||
shift
|
|
||||||
FRIENDS_MIRRORS_SERVER="$1"
|
|
||||||
;;
|
|
||||||
--remove)
|
--remove)
|
||||||
shift
|
shift
|
||||||
REMOVE="$1"
|
REMOVE="$1"
|
||||||
|
|
|
@ -1,288 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
#
|
|
||||||
# .---. . .
|
|
||||||
# | | |
|
|
||||||
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
||||||
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
||||||
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
||||||
#
|
|
||||||
# Freedom in the Cloud
|
|
||||||
#
|
|
||||||
# Mirror git repos which the project depends on
|
|
||||||
#
|
|
||||||
# License
|
|
||||||
# =======
|
|
||||||
#
|
|
||||||
# Copyright (C) 2015-2016 Bob Mottram <bob@freedombone.net>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero 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 Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero 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=$(cat /usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-passwords | grep 'MINIMUM_PASSWORD_LENGTH=' | head -n 1 | awk -F '=' '{print $2}')
|
|
||||||
|
|
||||||
CONFIGURATION_FILE="$HOME/${PROJECT_NAME}.cfg"
|
|
||||||
|
|
||||||
# used to mirror a single application
|
|
||||||
SYNC_SINGLE_APP=
|
|
||||||
|
|
||||||
# if this is blank then just use the default repos
|
|
||||||
FRIENDS_MIRRORS_SERVER=
|
|
||||||
UTILS_REPOS=
|
|
||||||
INSTALLED_APPS_REPOS=
|
|
||||||
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
|
|
||||||
|
|
||||||
# local repos for utils
|
|
||||||
UTILS_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
|
|
||||||
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 ''
|
|
||||||
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 [password] Friend's mirrors user password"
|
|
||||||
echo $" -m|--mypassword [password] 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=1
|
|
||||||
if [ ${#MY_MIRRORS_PASSWORD} -ge ${MINIMUM_PASSWORD_LENGTH} ]; then
|
|
||||||
create_password=
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $create_password ]; then
|
|
||||||
MY_MIRRORS_PASSWORD=$(openssl rand -base64 64 | tr -dc A-Za-z0-9 | head -c 18)
|
|
||||||
fi
|
|
||||||
|
|
||||||
chmod 600 /etc/shadow
|
|
||||||
chmod 600 /etc/gshadow
|
|
||||||
useradd -m -p "$MY_MIRRORS_PASSWORD" -s /bin/bash mirrors
|
|
||||||
chmod 0000 /etc/shadow
|
|
||||||
chmod 0000 /etc/gshadow
|
|
||||||
|
|
||||||
# remove any existing user files
|
|
||||||
rm -rf /home/mirrors/*
|
|
||||||
|
|
||||||
# store the mirrors password
|
|
||||||
write_config_param "MY_MIRRORS_PASSWORD" "${MY_MIRRORS_PASSWORD}"
|
|
||||||
}
|
|
||||||
|
|
||||||
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_installed_single_repo {
|
|
||||||
# only deal with a single app
|
|
||||||
filename=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${SYNC_SINGLE_APP}
|
|
||||||
if [ ! -f $filename ]; then
|
|
||||||
echo $"The app $SYNC_SINGLE_APP was not found"
|
|
||||||
exit 36822
|
|
||||||
fi
|
|
||||||
APP_REPOS=($(cat ${MAIN_COMMAND} $filename | grep "_REPO=\"" | grep -v "(cat " | uniq -u | sed 's|${PROJECT_NAME}|'"${PROJECT_NAME}"'|g'))
|
|
||||||
for line in "${APP_REPOS[@]}"
|
|
||||||
do
|
|
||||||
INSTALLED_APPS_REPOS+=("${line}")
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
function update_installed_apps_repos {
|
|
||||||
INSTALLED_APPS_REPOS=()
|
|
||||||
|
|
||||||
function_check app_is_installed
|
|
||||||
|
|
||||||
if [ $SYNC_SINGLE_APP ]; then
|
|
||||||
update_installed_single_repo
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
# all apps currently installed
|
|
||||||
FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
|
|
||||||
|
|
||||||
# for all the app scripts
|
|
||||||
for filename in $FILES
|
|
||||||
do
|
|
||||||
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
|
|
||||||
if [[ "$(app_is_installed ${app_name})" == "1" ]]; then
|
|
||||||
APP_REPOS=($(cat ${MAIN_COMMAND} $filename | grep "_REPO=\"" | grep -v "(cat " | uniq -u | sed 's|${PROJECT_NAME}|'"${PROJECT_NAME}"'|g'))
|
|
||||||
for line in "${APP_REPOS[@]}"
|
|
||||||
do
|
|
||||||
INSTALLED_APPS_REPOS+=("${line}")
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
function update_repos_from_friend_base {
|
|
||||||
syncrepos=${1}
|
|
||||||
new_repos=()
|
|
||||||
for line in $syncrepos
|
|
||||||
do
|
|
||||||
repo_name=$(echo "$line" | awk -F '=' '{print $1}')
|
|
||||||
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}"
|
|
||||||
new_line="${repo_name}=\"${friends_repo_url}\""
|
|
||||||
new_repos+=($new_line)
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
function update_repos_from_friend {
|
|
||||||
if [ ! $FRIENDS_MIRRORS_SERVER ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if [ ${#FRIENDS_MIRRORS_SERVER} -lt 2 ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
update_repos_from_friend_base "${UTILS_REPOS[@]}"
|
|
||||||
UTILS_REPOS=("${new_repos[@]}")
|
|
||||||
|
|
||||||
update_repos_from_friend_base "${INSTALLED_APPS_REPOS[@]}"
|
|
||||||
INSTALLED_APPS_REPOS=("${new_repos[@]}")
|
|
||||||
}
|
|
||||||
|
|
||||||
function sync_mirrors_base {
|
|
||||||
syncrepos=${1}
|
|
||||||
for line in $syncrepos
|
|
||||||
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' && ${mirrors_name} != 'cmake' ]]; 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
|
|
||||||
}
|
|
||||||
|
|
||||||
function sync_mirrors_repos {
|
|
||||||
if [ ! $SYNC_SINGLE_APP ]; then
|
|
||||||
sync_mirrors_base "${UTILS_REPOS[@]}"
|
|
||||||
fi
|
|
||||||
sync_mirrors_base "${INSTALLED_APPS_REPOS[@]}"
|
|
||||||
}
|
|
||||||
|
|
||||||
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"
|
|
||||||
write_config_param "MY_MIRRORS_PASSWORD" "${MY_MIRRORS_PASSWORD}"
|
|
||||||
;;
|
|
||||||
-p|--pass|--password)
|
|
||||||
shift
|
|
||||||
FRIENDS_MIRRORS_PASSWORD="$1"
|
|
||||||
write_config_param "FRIENDS_MIRRORS_PASSWORD" "${FRIENDS_MIRRORS_PASSWORD}"
|
|
||||||
;;
|
|
||||||
-n|--new)
|
|
||||||
shift
|
|
||||||
NEW_MIRRORS="$1"
|
|
||||||
;;
|
|
||||||
--port)
|
|
||||||
shift
|
|
||||||
FRIENDS_MIRRORS_SSH_PORT=${1}
|
|
||||||
;;
|
|
||||||
-a|--app)
|
|
||||||
shift
|
|
||||||
SYNC_SINGLE_APP="${1}"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
# unknown option
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
shift
|
|
||||||
done
|
|
||||||
|
|
||||||
create_mirrors_user
|
|
||||||
enable_mirrors_via_onion
|
|
||||||
update_installed_apps_repos
|
|
||||||
update_repos_from_friend
|
|
||||||
sync_mirrors_repos
|
|
||||||
|
|
||||||
exit 0
|
|
|
@ -37,10 +37,6 @@ CONFIGURATION_FILE="$HOME/${PROJECT_NAME}.cfg"
|
||||||
|
|
||||||
PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"
|
PROJECT_REPO="https://github.com/bashrc/${PROJECT_NAME}"
|
||||||
|
|
||||||
FRIENDS_MIRRORS_SERVER=
|
|
||||||
FRIENDS_MIRRORS_SSH_PORT=2222
|
|
||||||
FRIENDS_MIRRORS_PASSWORD=
|
|
||||||
MY_MIRRORS_PASSWORD=
|
|
||||||
CURRENT_BRANCH=master
|
CURRENT_BRANCH=master
|
||||||
|
|
||||||
# clear temporary files
|
# clear temporary files
|
||||||
|
@ -71,9 +67,6 @@ fi
|
||||||
|
|
||||||
update-ca-certificates
|
update-ca-certificates
|
||||||
|
|
||||||
read_repo_servers
|
|
||||||
#${PROJECT_NAME}-mirrors
|
|
||||||
|
|
||||||
if [ ! -d $PROJECT_DIR ]; then
|
if [ ! -d $PROJECT_DIR ]; then
|
||||||
git_clone $PROJECT_REPO $PROJECT_DIR
|
git_clone $PROJECT_REPO $PROJECT_DIR
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -28,11 +28,7 @@
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
configuration_variables=(FRIENDS_MIRRORS_SERVER
|
configuration_variables=(SYSTEM_TYPE
|
||||||
FRIENDS_MIRRORS_SSH_PORT
|
|
||||||
FRIENDS_MIRRORS_PASSWORD
|
|
||||||
MY_MIRRORS_PASSWORD
|
|
||||||
SYSTEM_TYPE
|
|
||||||
SSL_PROTOCOLS
|
SSL_PROTOCOLS
|
||||||
SSL_CIPHERS
|
SSL_CIPHERS
|
||||||
SSH_CIPHERS
|
SSH_CIPHERS
|
||||||
|
@ -302,8 +298,6 @@ function read_configuration_values {
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f $CONFIGURATION_FILE ]; then
|
if [ -f $CONFIGURATION_FILE ]; then
|
||||||
read_repo_servers
|
|
||||||
|
|
||||||
# Ensure that a copy of the config exists for upgrade purposes
|
# Ensure that a copy of the config exists for upgrade purposes
|
||||||
if [[ $CONFIGURATION_FILE != "/root/${PROJECT_NAME}.cfg" ]]; then
|
if [[ $CONFIGURATION_FILE != "/root/${PROJECT_NAME}.cfg" ]]; then
|
||||||
cp $CONFIGURATION_FILE /root/${PROJECT_NAME}.cfg
|
cp $CONFIGURATION_FILE /root/${PROJECT_NAME}.cfg
|
||||||
|
|
|
@ -32,19 +32,6 @@ function git_clone {
|
||||||
repo_url="$1"
|
repo_url="$1"
|
||||||
destination_dir="$2"
|
destination_dir="$2"
|
||||||
|
|
||||||
if [[ "$repo_url" == 'ssh:'* ]]; then
|
|
||||||
if [ "${FRIENDS_MIRRORS_SERVER}" ]; then
|
|
||||||
if [ ${#FRIENDS_MIRRORS_SERVER} -gt 2 ]; then
|
|
||||||
if [ "$FRIENDS_MIRRORS_PASSWORD" ]; then
|
|
||||||
if [ ${#FRIENDS_MIRRORS_PASSWORD} -gt 2 ]; then
|
|
||||||
echo "sshpass -p \"$FRIENDS_MIRRORS_PASSWORD\" git clone $repo_url $destination_dir"
|
|
||||||
sshpass -p "$FRIENDS_MIRRORS_PASSWORD" git clone "$repo_url" "$destination_dir"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
echo "git clone $repo_url $destination_dir"
|
echo "git clone $repo_url $destination_dir"
|
||||||
git clone --recursive "$repo_url" "$destination_dir"
|
git clone --recursive "$repo_url" "$destination_dir"
|
||||||
}
|
}
|
||||||
|
@ -58,19 +45,6 @@ function git_pull {
|
||||||
git stash
|
git stash
|
||||||
git remote set-url origin $1
|
git remote set-url origin $1
|
||||||
git checkout master
|
git checkout master
|
||||||
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
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
git pull
|
git pull
|
||||||
|
|
||||||
if [ $2 ]; then
|
if [ $2 ]; then
|
||||||
|
|
|
@ -31,13 +31,6 @@
|
||||||
# The Debian package repository to use.
|
# The Debian package repository to use.
|
||||||
DEBIAN_REPO="ftp.us.debian.org"
|
DEBIAN_REPO="ftp.us.debian.org"
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
function create_repo_sources {
|
function create_repo_sources {
|
||||||
if [[ $(is_completed $FUNCNAME) == "1" ]]; then
|
if [[ $(is_completed $FUNCNAME) == "1" ]]; then
|
||||||
return
|
return
|
||||||
|
@ -63,46 +56,6 @@ function create_repo_sources {
|
||||||
mark_completed $FUNCNAME
|
mark_completed $FUNCNAME
|
||||||
}
|
}
|
||||||
|
|
||||||
function read_repo_servers {
|
|
||||||
read_config_param FRIENDS_MIRRORS_SERVER
|
|
||||||
read_config_param FRIENDS_MIRRORS_SSH_PORT
|
|
||||||
read_config_param MY_MIRRORS_PASSWORD
|
|
||||||
read_config_param FRIENDS_MIRRORS_PASSWORD
|
|
||||||
|
|
||||||
if [ ! $FRIENDS_MIRRORS_SERVER ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
if [ ${#FRIENDS_MIRRORS_SERVER} -lt 2 ]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
APP_FILES=/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-*
|
|
||||||
for f in $APP_FILES
|
|
||||||
do
|
|
||||||
REPOS=($(cat ${f} | grep "_REPO=\"" | uniq -u | sed 's|${PROJECT_NAME}|'"${PROJECT_NAME}"'|g'))
|
|
||||||
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)}')
|
|
||||||
friends_repo_url="ssh://mirrors@${FRIENDS_MIRRORS_SERVER}:${FRIENDS_MIRRORS_SSH_PORT}/home/mirrors/${mirrors_name}"
|
|
||||||
export ${repo_name}="${friends_repo_url}"
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
APP_FILES=/usr/share/${PROJECT_NAME}/utils/${PROJECT_NAME}-utils-*
|
|
||||||
for f in $APP_FILES
|
|
||||||
do
|
|
||||||
REPOS=($(cat ${f} | grep "_REPO=\"" | uniq -u | sed 's|${PROJECT_NAME}|'"${PROJECT_NAME}"'|g'))
|
|
||||||
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)}')
|
|
||||||
friends_repo_url="ssh://mirrors@${FRIENDS_MIRRORS_SERVER}:${FRIENDS_MIRRORS_SSH_PORT}/home/mirrors/${mirrors_name}"
|
|
||||||
export ${repo_name}="${friends_repo_url}"
|
|
||||||
done
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# A command to create a git repository for a project
|
# A command to create a git repository for a project
|
||||||
function create_git_project {
|
function create_git_project {
|
||||||
if [[ $(is_completed $FUNCNAME) == "1" ]]; then
|
if [[ $(is_completed $FUNCNAME) == "1" ]]; then
|
||||||
|
@ -136,15 +89,4 @@ function create_git_project {
|
||||||
mark_completed $FUNCNAME
|
mark_completed $FUNCNAME
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_mirrors {
|
|
||||||
if [ -d /home/trove ]; then
|
|
||||||
userdel -r trove
|
|
||||||
fi
|
|
||||||
if [[ $(is_completed $FUNCNAME) == "1" ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
#${PROJECT_NAME}-mirrors
|
|
||||||
mark_completed $FUNCNAME
|
|
||||||
}
|
|
||||||
|
|
||||||
# NOTE: deliberately no exit 0
|
# NOTE: deliberately no exit 0
|
||||||
|
|
|
@ -572,8 +572,6 @@ function install_apps {
|
||||||
function_check add_users_after_install
|
function_check add_users_after_install
|
||||||
add_users_after_install ${a}
|
add_users_after_install ${a}
|
||||||
|
|
||||||
#${PROJECT_NAME}-mirrors --app ${a}
|
|
||||||
|
|
||||||
function_check lockdown_permissions
|
function_check lockdown_permissions
|
||||||
lockdown_permissions
|
lockdown_permissions
|
||||||
|
|
||||||
|
@ -609,8 +607,6 @@ function install_apps {
|
||||||
function_check lockdown_permissions
|
function_check lockdown_permissions
|
||||||
lockdown_permissions
|
lockdown_permissions
|
||||||
|
|
||||||
#${PROJECT_NAME}-mirrors --app ${a}
|
|
||||||
|
|
||||||
function_check install_completed
|
function_check install_completed
|
||||||
install_completed ${a}
|
install_completed ${a}
|
||||||
echo $"${a} was installed"
|
echo $"${a} was installed"
|
||||||
|
|
|
@ -836,9 +836,6 @@ function setup_utils {
|
||||||
function_check regenerate_ssh_keys
|
function_check regenerate_ssh_keys
|
||||||
regenerate_ssh_keys
|
regenerate_ssh_keys
|
||||||
|
|
||||||
function_check create_mirrors
|
|
||||||
create_mirrors
|
|
||||||
|
|
||||||
function_check create_upgrade_script
|
function_check create_upgrade_script
|
||||||
create_upgrade_script
|
create_upgrade_script
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ function validate_freedns_code {
|
||||||
|
|
||||||
function is_valid_user {
|
function is_valid_user {
|
||||||
USRNAME="$1"
|
USRNAME="$1"
|
||||||
if [[ "$USRNAME" != "turtl" && "$USRNAME" != "znc" && "$USRNAME" != "pihole" && "$USRNAME" != "fbone" && "$USRNAME" != "go" && "$USRNAME" != "gogs" && "$USRNAME" != "git" && "$USRNAME" != "mirrors" && "$USRNAME" != "sync" && "$USRNAME" != "tahoelafs" ]]; then
|
if [[ "$USRNAME" != "turtl" && "$USRNAME" != "znc" && "$USRNAME" != "pihole" && "$USRNAME" != "fbone" && "$USRNAME" != "go" && "$USRNAME" != "gogs" && "$USRNAME" != "git" && "$USRNAME" != "sync" && "$USRNAME" != "tahoelafs" ]]; then
|
||||||
echo "1"
|
echo "1"
|
||||||
else
|
else
|
||||||
echo "0"
|
echo "0"
|
||||||
|
|
Loading…
Reference in New Issue