This commit is contained in:
Bob Mottram 2018-03-08 17:42:50 +00:00
commit 4701bf16a9
18 changed files with 111 additions and 56 deletions

View File

@ -72,7 +72,8 @@ function mark_unselected_apps_as_removed {
fi
app_index=0
for app_name in "${APPS_AVAILABLE[@]}"
# shellcheck disable=SC2068
for app_name in ${APPS_AVAILABLE[@]}
do
if [[ ${APPS_CHOSEN[$app_index]} == "0" ]]; then
echo "_${app_name}_" >> "$REMOVED_APPS_FILE"
@ -106,7 +107,8 @@ function show_apps {
applist=""
n=1
app_index=0
for a in "${APPS_AVAILABLE[@]}"
# shellcheck disable=SC2068
for a in ${APPS_AVAILABLE[@]}
do
if [[ ${APPS_INSTALLED[$app_index]} == "0" && "$select_all_apps" != "add-all" ]]; then
applist="$applist $n $a off"
@ -144,7 +146,8 @@ function remove_apps_selected {
removals=""
app_index=0
n=0
for a in "${APPS_INSTALLED[@]}"
# shellcheck disable=SC2068
for a in ${APPS_INSTALLED[@]}
do
if [[ ${APPS_INSTALLED[$app_index]} == "1" ]]; then
if [[ ${APPS_CHOSEN[$app_index]} == "0" ]]; then
@ -188,7 +191,8 @@ function install_apps_selected {
installs=""
app_index=0
n=0
for a in "${APPS_INSTALLED[@]}"
# shellcheck disable=SC2068
for a in ${APPS_INSTALLED[@]}
do
if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then

View File

@ -211,7 +211,8 @@ chmod 600 "/home/$ADD_USERNAME/README"
echo $'Detecting installed apps...'
detect_apps
get_apps_installed_names
for app_name in "${APPS_INSTALLED_NAMES[@]}"
# shellcheck disable=SC2068
for app_name in ${APPS_INSTALLED_NAMES[@]}
do
if [[ $(function_exists "add_user_${app_name}") == "1" ]]; then
echo $"Adding user to ${app_name}"

View File

@ -295,7 +295,8 @@ function pelican_change_theme {
if [ -f $PELICAN_BLOG_INSTALL_DIR/.blog-theme-index ]; then
curr_theme_index=$(cat $PELICAN_BLOG_INSTALL_DIR/.blog-theme-index)
fi
for a in "${THEMES[@]}"
# shellcheck disable=SC2068
for a in ${THEMES[@]}
do
is_selected='off'
if [ "$curr_theme_index" ]; then

View File

@ -47,7 +47,7 @@ PLEROMA_CODE=
PLEROMA_PORT=4000
PLEROMA_ONION_PORT=8011
PLEROMA_REPO="https://git.pleroma.social/pleroma/pleroma.git"
PLEROMA_COMMIT='2f291576e4eef95e6867348e24bc526058518095'
PLEROMA_COMMIT='460062f2b04220ffcd8f20aa842cc95582d1f849'
PLEROMA_ADMIN_PASSWORD=
PLEROMA_DIR=/etc/pleroma
PLEROMA_SECRET_KEY=""
@ -180,7 +180,7 @@ function expire_pleroma_posts {
echo '';
echo '# copy the avatar files to a temporary directory';
echo "arr=( \$avatars )";
echo "for i in \"\${arr[@]}\"; do";
echo "for i in \${arr[@]}; do";
echo " if [[ \"\$i\" == *'/media/'* ]]; then";
echo " imagefile=/etc/pleroma/uploads/\$(echo \$i | sed 's|\"||g' | sed 's|,||g' | awk -F '/media/' '{print \$2}');";
echo " if [ -f \$imagefile ]; then";
@ -203,7 +203,7 @@ function expire_pleroma_posts {
echo '';
echo '# copy the banner files to a temporary directory';
echo "arr=( \$banners )";
echo "for i in \"\${arr[@]}\"; do";
echo "for i in \${arr[@]}; do";
echo " if [[ \"\$i\" == *'/media/'* ]]; then";
echo " imagefile=/etc/pleroma/uploads/\$(echo \$i | sed 's|\"||g' | sed 's|,||g' | awk -F '/media/' '{print \$2}');";
echo " if [ -f \$imagefile ]; then";
@ -570,11 +570,15 @@ function pleroma_disable_registrations {
--yesno $"\\nDo you wish to disable new registrations?" 10 60
sel=$?
case $sel in
0) sed -i 's|registrations_open:.*|registrations_open: false,|g' $PLEROMA_DIR/config/config.exs
sed -i 's|"registrationOpen":.*|"registrationOpen": false,|g' $PLEROMA_DIR/priv/static/static/config.json
0) sed -i 's|registrations_open: true|registrations_open: false|g' $PLEROMA_DIR/config/config.exs
sed -i 's|registrations_open: True|registrations_open: false|g' $PLEROMA_DIR/config/config.exs
sed -i 's|"registrationOpen": true|"registrationOpen": false|g' $PLEROMA_DIR/priv/static/static/config.json
sed -i 's|"registrationOpen": True|"registrationOpen": false|g' $PLEROMA_DIR/priv/static/static/config.json
;;
1) sed -i 's|registrations_open:.*|registrations_open: true,|g' $PLEROMA_DIR/config/config.exs
sed -i 's|"registrationOpen":.*|"registrationOpen": true,|g' $PLEROMA_DIR/priv/static/static/config.json
1) sed -i 's|registrations_open: false|registrations_open: true|g' $PLEROMA_DIR/config/config.exs
sed -i 's|registrations_open: False|registrations_open: true|g' $PLEROMA_DIR/config/config.exs
sed -i 's|"registrationOpen": false|"registrationOpen": true|g' $PLEROMA_DIR/priv/static/static/config.json
sed -i 's|"registrationOpen": False|"registrationOpen": true|g' $PLEROMA_DIR/priv/static/static/config.json
;;
255) return;;
esac
@ -755,8 +759,12 @@ function upgrade_pleroma {
fi
sudo -u pleroma mix deps.get
pleroma_recompile
# migrate database
sudo -u pleroma mix deps.clean --build mime
expire_pleroma_posts "$PLEROMA_DOMAIN_NAME" "$PLEROMA_EXPIRE_MONTHS"
create_pleroma_blocklist

View File

@ -228,7 +228,8 @@ function backup_directories {
"/root/.passwords, passwordstore"
)
for dr in "${backup_dirs[@]}"
# shellcheck disable=SC2068
for dr in ${backup_dirs[@]}
do
# if this directory exists then back it up to the given destination
source_directory=$(echo "$dr" | awk -F ',' '{print $1}' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')

View File

@ -798,7 +798,8 @@ function choose_system_variant {
varslist=""
n=1
for a in "${available_variants_list[@]}"
# shellcheck disable=SC2068
for a in ${available_variants_list[@]}
do
varstate='off'
if [[ "$a" == $'full' || "$a" == $'Full' ]]; then
@ -1057,7 +1058,8 @@ function select_user {
users_array=($homedirs)
delete=(git)
for del in "${delete[@]}"
# shellcheck disable=SC2068
for del in ${delete[@]}
do
# shellcheck disable=SC2206
users_array=(${users_array[@]/$del})

View File

@ -230,7 +230,8 @@ function passwords_show_apps {
i=0
W=()
name=()
for a in "${APPS_AVAILABLE[@]}"
# shellcheck disable=SC2068
for a in ${APPS_AVAILABLE[@]}
do
if [[ $(function_exists "change_password_${a}") == "1" ]]; then
i=$((i+1))
@ -410,7 +411,8 @@ function show_domains {
grep 'sks onion domain' "${COMPLETION_FILE}" | awk -F ':' '{print $2}'
fi
for app_name in "${APPS_INSTALLED_NAMES[@]}"
# shellcheck disable=SC2068
for app_name in ${APPS_INSTALLED_NAMES[@]}
do
if ! grep -q "SHOW_ON_ABOUT=1" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then
continue
@ -1129,7 +1131,8 @@ function restore_data_from_storage {
app_list+=("$AllStr")
util_index=0
for a in "${utils_installed[@]}"
# shellcheck disable=SC2068
for a in ${utils_installed[@]}
do
applist="$applist $n $a off"
app_name=${utils_installed[util_index]}
@ -1139,7 +1142,8 @@ function restore_data_from_storage {
done
app_index=0
for a in "${APPS_INSTALLED_NAMES[@]}"
# shellcheck disable=SC2068
for a in ${APPS_INSTALLED_NAMES[@]}
do
applist="$applist $n $a off"
n=$((n+1))
@ -2233,7 +2237,8 @@ function menu_app_settings {
appnames=()
n=1
app_index=0
for a in "${APPS_AVAILABLE[@]}"
# shellcheck disable=SC2068
for a in ${APPS_AVAILABLE[@]}
do
if [[ ${APPS_INSTALLED[$app_index]} != "0" ]]; then
if [[ $(function_exists "configure_interactive_${a}") == "1" ]]; then

View File

@ -837,7 +837,8 @@ function menu_run_client_app {
appnames=()
n=1
app_index=0
for a in "${APPS_AVAILABLE[@]}"
# shellcheck disable=SC2068
for a in ${APPS_AVAILABLE[@]}
do
if [[ ${APPS_INSTALLED[$app_index]} != "0" ]]; then
if [[ $(function_exists "run_client_${a}") == "1" ]]; then

View File

@ -55,7 +55,8 @@ detected_codes=()
codelines=$(grep "_CODE=" "$CONFIGURATION_FILE" | uniq)
while read -r line; do
code=$(echo "$line" | awk -F '=' '{print $2}')
if ! item_in_array "$code" "${detected_codes[@]}"; then
# shellcheck disable=SC2068
if ! item_in_array "$code" ${detected_codes[@]}; then
detected_codes+=("$code")
fi
done <<< "$codelines"
@ -64,7 +65,8 @@ if [ ! -d "$HOME/.freedns-update" ]; then
mkdir "$HOME/.freedns-update"
fi
cd "$HOME/.freedns-update" || exit 2467824684
for code in "${detected_codes[@]}"
# shellcheck disable=SC2068
for code in ${detected_codes[@]}
do
if [ $VERBOSE ]; then
echo $"command: $FREEDNS_WGET${code}="

View File

@ -482,7 +482,8 @@ fi
# Move any existing images into a build subdirectory
image_types=( xz img sig vdi qcow2 )
for im in "${image_types[@]}"
# shellcheck disable=SC2068
for im in ${image_types[@]}
do
# shellcheck disable=SC2012,SC2086
no_of_files=$(ls -afq ${CURR_DIR}/${PROJECT_NAME}*.${im} | wc -l)
@ -496,7 +497,8 @@ do
done
# Delete anything which didn't move
for im in "${image_types[@]}"
# shellcheck disable=SC2068
for im in ${image_types[@]}
do
# shellcheck disable=SC2012,SC2086
no_of_files=$(ls -afq ${CURR_DIR}/${PROJECT_NAME}*.${im} | wc -l)
@ -624,7 +626,8 @@ if [ ${#imgfiles[@]} -eq 0 ]; then
fi
# Move images from temporary directory to the current directory
for im in "${image_types[@]}"
# shellcheck disable=SC2068
for im in ${image_types[@]}
do
# shellcheck disable=SC2012,SC2086
no_of_files=$(ls -afq build/${PROJECT_NAME}*.${im} | wc -l)

View File

@ -73,7 +73,8 @@ function logging_get_app_names {
function turn_logging_on {
logging_get_app_names
for a in "${APPS_AVAILABLE[@]}"
# shellcheck disable=SC2068
for a in ${APPS_AVAILABLE[@]}
do
echo $"Turning on logging for ${a}"
"logging_on_${a}"
@ -83,7 +84,8 @@ function turn_logging_on {
function turn_logging_off {
logging_get_app_names
for a in "${APPS_AVAILABLE[@]}"
# shellcheck disable=SC2068
for a in ${APPS_AVAILABLE[@]}
do
echo $"Turning off logging for ${a}"
"logging_off_${a}"

View File

@ -187,7 +187,8 @@ function change_theme {
if [ -f /tmp/.blog-themes ]; then
rm /tmp/.blog-themes
fi
for a in "${THEMES[@]}"
# shellcheck disable=SC2068
for a in ${THEMES[@]}
do
echo "$n $a" >> /tmp/.blog-themes
n=$((n+1))

View File

@ -124,7 +124,8 @@ fi
echo $'Detecting installed apps...'
detect_apps
get_apps_installed_names
for app_name in "${APPS_INSTALLED_NAMES[@]}"
# shellcheck disable=SC2068
for app_name in ${APPS_INSTALLED_NAMES[@]}
do
if [[ $(function_exists "remove_user_${app_name}") == "1" ]]; then
echo $"Removing user from ${app_name}"

View File

@ -124,7 +124,8 @@ function test_app_functions {
for filename in $FILES
do
# for each expected interface function
for f in "${interface_functions[@]}"
# shellcheck disable=SC2068
for f in ${interface_functions[@]}
do
test_app_function_type "${filename}" "$f"
done

View File

@ -543,7 +543,8 @@ function backup_apps {
detect_installable_apps
get_apps_installed_names
for app_name in "${APPS_INSTALLED_NAMES[@]}"
# shellcheck disable=SC2068
for app_name in ${APPS_INSTALLED_NAMES[@]}
do
echo $"Backup ${app_name}"
app_load_variables "${app_name}"
@ -563,7 +564,8 @@ function restore_apps {
detect_installable_apps
get_apps_installed_names
for app_name in "${APPS_INSTALLED_NAMES[@]}"
# shellcheck disable=SC2068
for app_name in ${APPS_INSTALLED_NAMES[@]}
do
confirm_restore=
if [ ! "$2" ]; then
@ -807,7 +809,8 @@ function valid_backup_destination {
available_variants_list=()
available_system_variants
if ! item_in_array "${destination_dir}" "${available_variants_list[@]}"; then
# shellcheck disable=SC2068
if ! item_in_array "${destination_dir}" ${available_variants_list[@]}; then
is_valid="no"
fi

View File

@ -279,7 +279,8 @@ function remove_completion_param {
}
function save_configuration_values {
for v in "${configuration_variables[@]}"
# shellcheck disable=SC2068
for v in ${configuration_variables[@]}
do
write_config_param "$v" "${!v}"
done
@ -299,7 +300,8 @@ function read_configuration_values {
cp "$CONFIGURATION_FILE" "/root/${PROJECT_NAME}.cfg"
fi
for v in "${configuration_variables[@]}"
# shellcheck disable=SC2068
for v in ${configuration_variables[@]}
do
read_config_param "$v"
done
@ -337,13 +339,14 @@ function check_domains {
domains_array=("$specified_domains")
checked_domains=()
for d in "${domains_array[@]}"
# shellcheck disable=SC2068
for d in ${domains_array[@]}
do
domain_param=$(echo "$d" | awk -F '=' '{print $1}')
if [[ "$domain_param" != "DEFAULT_DOMAIN_NAME" ]]; then
domain_value=$(echo "$d" | awk -F '=' '{print $2}')
if [[ "$domain_value" != "${LOCAL_NAME}.local" ]]; then
if ! item_in_array "${domain_value}" "${checked_domains[@]}"; then
if ! item_in_array "${domain_value}" ${checked_domains[@]}; then
# test that this is a valid domain name
function_check test_domain_name
test_domain_name "$domain_value"

View File

@ -69,7 +69,8 @@ function app_load_variables {
#shellcheck disable=SC2206
configvarname=( ${!configvarname} )
for v in "${configvarname[@]}"
# shellcheck disable=SC2068
for v in ${configvarname[@]}
do
read_config_param "$v"
done
@ -90,7 +91,8 @@ function app_save_variables {
#shellcheck disable=SC2206
configvarname=( ${!configvarname} )
for v in "${configvarname[@]}"
# shellcheck disable=SC2068
for v in ${configvarname[@]}
do
write_config_param "$v" "${!v}"
done
@ -128,9 +130,10 @@ function available_system_variants {
system_variants_list=$(app_variants "$filename")
# shellcheck disable=SC2206
variants_array=($system_variants_list)
for variant_str in "${variants_array[@]}"
# shellcheck disable=SC2068
for variant_str in ${variants_array[@]}
do
if ! item_in_array "${variant_str}" "${new_available_variants_list[@]}"; then
if ! item_in_array "${variant_str}" ${new_available_variants_list[@]}; then
new_available_variants_list+=("$variant_str")
fi
done
@ -146,7 +149,8 @@ function is_valid_variant {
function_check available_system_variants
available_system_variants
for variant_str in "${available_variants_list[@]}"
# shellcheck disable=SC2068
for variant_str in ${available_variants_list[@]}
do
if [[ "$sys_type" == "$variant_str" ]]; then
return "1"
@ -161,7 +165,8 @@ function show_available_variants {
function_check available_system_variants
available_system_variants
for variant_str in "${available_variants_list[@]}"
# shellcheck disable=SC2068
for variant_str in ${available_variants_list[@]}
do
echo " $variant_str"
done
@ -250,7 +255,8 @@ function install_completed {
# populates an array of "0" or "1" for whether apps are installed
function get_apps_installed {
for a in "${APPS_AVAILABLE[@]}"
# shellcheck disable=SC2068
for a in ${APPS_AVAILABLE[@]}
do
APPS_INSTALLED+=("$(app_is_installed "$a")")
done
@ -259,7 +265,8 @@ function get_apps_installed {
# populates an array of installed app names
function get_apps_installed_names {
APPS_INSTALLED_NAMES=()
for a in "${APPS_AVAILABLE[@]}"
# shellcheck disable=SC2068
for a in ${APPS_AVAILABLE[@]}
do
if [[ $(app_is_installed "$a") == "1" ]]; then
APPS_INSTALLED_NAMES+=("$a")
@ -281,7 +288,8 @@ function detect_apps {
do
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
if ! item_in_array "${app_name}" "${APPS_AVAILABLE[@]}"; then
# shellcheck disable=SC2068
if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
APPS_AVAILABLE+=("${app_name}")
APPS_CHOSEN+=("0")
fi
@ -312,7 +320,8 @@ function detect_installable_apps {
do
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
if ! item_in_array "${app_name}" "${APPS_AVAILABLE[@]}"; then
# shellcheck disable=SC2068
if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
variants_list=$(app_variants "$filename")
# check for empty string
if [ ${#variants_list} -gt 0 ]; then
@ -344,7 +353,8 @@ function detect_installed_apps {
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
if [[ $(app_is_installed "$app_name") == "1" ]]; then
if ! item_in_array "${app_name}" "${APPS_AVAILABLE[@]}"; then
# shellcheck disable=SC2068
if ! item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
variants_list=$(app_variants "$filename")
if [ ${#variants_list} -gt 0 ]; then
APPS_AVAILABLE+=("${app_name}")
@ -378,7 +388,8 @@ function choose_apps_for_variant {
do
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
if item_in_array "${app_name}" "${APPS_AVAILABLE[@]}"; then
# shellcheck disable=SC2068
if item_in_array "${app_name}" ${APPS_AVAILABLE[@]}; then
if grep -q "VARIANTS=" "${filename}"; then
variants_list=$(app_variants "$filename")
if [[ "${variants_list}" == 'all'* || \
@ -408,7 +419,8 @@ function choose_apps_for_variant {
# show a list of apps which have been chosen
function list_chosen_apps {
app_index=0
for a in "${APPS_AVAILABLE[@]}"
# shellcheck disable=SC2068
for a in ${APPS_AVAILABLE[@]}
do
if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then
echo $"${a}"
@ -419,7 +431,8 @@ function list_chosen_apps {
function remove_apps {
app_index=0
for a in "${APPS_AVAILABLE[@]}"
# shellcheck disable=SC2068
for a in ${APPS_AVAILABLE[@]}
do
if [[ ${APPS_INSTALLED[$app_index]} == "1" ]]; then
if [[ ${APPS_CHOSEN[$app_index]} == "0" ]]; then
@ -450,7 +463,8 @@ function remove_apps {
function install_apps_interactive {
echo $"Interactive installer"
app_index=0
for a in "${APPS_AVAILABLE[@]}"
# shellcheck disable=SC2068
for a in ${APPS_AVAILABLE[@]}
do
if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then
@ -546,7 +560,8 @@ function install_apps {
# now install the apps
app_index=0
for a in "${APPS_AVAILABLE[@]}"
# shellcheck disable=SC2068
for a in ${APPS_AVAILABLE[@]}
do
if [[ ${APPS_INSTALLED[$app_index]} == "0" ]]; then
if [[ ${APPS_CHOSEN[$app_index]} == "1" ]]; then

View File

@ -1105,7 +1105,8 @@ function upgrade_apps {
do
app_name=$(echo "${filename}" | awk -F '-app-' '{print $2}')
if ! item_in_array "${app_name}" "${APPS_COMPLETED[@]}"; then
# shellcheck disable=SC2068
if ! item_in_array "${app_name}" ${APPS_COMPLETED[@]}; then
function_check app_is_installed
if [[ "$(app_is_installed "$app_name")" == "1" ]]; then
echo ''