A few minor fixes to copyparty.
This commit is contained in:
+77
-15
@@ -50,6 +50,40 @@ detect_private_subnets() {
|
|||||||
'
|
'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
detect_first_private_ipv4() {
|
||||||
|
ip -o -4 addr show up scope global | awk '
|
||||||
|
{
|
||||||
|
split($4, parts, "/")
|
||||||
|
split(parts[1], octets, ".")
|
||||||
|
|
||||||
|
if (octets[1] == 10 ||
|
||||||
|
(octets[1] == 192 && octets[2] == 168) ||
|
||||||
|
(octets[1] == 172 && octets[2] >= 16 && octets[2] <= 31)) {
|
||||||
|
print parts[1]
|
||||||
|
exit 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'
|
||||||
|
}
|
||||||
|
|
||||||
|
show_copyparty_address() {
|
||||||
|
local lanAddress=""
|
||||||
|
|
||||||
|
if ! copyparty_installed; then
|
||||||
|
msgbox "Copyparty is not installed."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
lanAddress="$(detect_first_private_ipv4)"
|
||||||
|
if [[ -z "$lanAddress" ]]; then
|
||||||
|
msgbox "Copyparty is installed, but no private IPv4 address could be detected automatically."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
msgbox "Copyparty should be available at http://${lanAddress}:${copypartyPort}"
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
choose_lan_subnet() {
|
choose_lan_subnet() {
|
||||||
local detectedSubnet=""
|
local detectedSubnet=""
|
||||||
local subnetChoice=""
|
local subnetChoice=""
|
||||||
@@ -433,22 +467,50 @@ configure_copyparty_firewall() {
|
|||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
serviceUser="$(choose_copyparty_user)" || return 1
|
install_copyparty_flow() {
|
||||||
install_copyparty || return 1
|
local serviceUser=""
|
||||||
accountsFile="$(collect_copyparty_accounts)" || return 1
|
local unitName=""
|
||||||
usernamesCsv="$(join_account_names "$accountsFile")"
|
local accountsFile=""
|
||||||
sharesFile="$(collect_copyparty_shares "$usernamesCsv" "$serviceUser")" || {
|
local usernamesCsv=""
|
||||||
rm -f "$accountsFile"
|
local sharesFile=""
|
||||||
return 1
|
local lanAddress=""
|
||||||
}
|
|
||||||
|
|
||||||
write_copyparty_config "$serviceUser" "$accountsFile" "$sharesFile" || {
|
serviceUser="$(choose_copyparty_user)" || return 1
|
||||||
|
unitName="copyparty@${serviceUser}.service"
|
||||||
|
install_copyparty || return 1
|
||||||
|
accountsFile="$(collect_copyparty_accounts)" || return 1
|
||||||
|
usernamesCsv="$(join_account_names "$accountsFile")"
|
||||||
|
sharesFile="$(collect_copyparty_shares "$usernamesCsv" "$serviceUser")" || {
|
||||||
|
rm -f "$accountsFile"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
write_copyparty_config "$serviceUser" "$accountsFile" "$sharesFile" || {
|
||||||
|
rm -f "$accountsFile" "$sharesFile"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
rm -f "$accountsFile" "$sharesFile"
|
rm -f "$accountsFile" "$sharesFile"
|
||||||
return 1
|
|
||||||
|
enable_copyparty_service "$serviceUser" || return 1
|
||||||
|
configure_copyparty_firewall || return 1
|
||||||
|
|
||||||
|
lanAddress="$(detect_first_private_ipv4)"
|
||||||
|
if [[ -n "$lanAddress" ]]; then
|
||||||
|
msgbox "Copyparty is configured. Enabled unit: ${unitName}. It should now be available at http://${lanAddress}:${copypartyPort}. For advanced tuning, edit ${copypartyConfigFile} as root."
|
||||||
|
else
|
||||||
|
msgbox "Copyparty is configured. Enabled unit: ${unitName}. For advanced tuning, edit ${copypartyConfigFile} as root."
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
rm -f "$accountsFile" "$sharesFile"
|
|
||||||
|
|
||||||
enable_copyparty_service "$serviceUser" || return 1
|
case "${1:-install}" in
|
||||||
configure_copyparty_firewall || return 1
|
install)
|
||||||
|
install_copyparty_flow
|
||||||
msgbox "Copyparty is configured. For advanced tuning, edit ${copypartyConfigFile} as root."
|
;;
|
||||||
|
show-address)
|
||||||
|
show_copyparty_address
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
msgbox "Unknown Copyparty action: ${1}"
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|||||||
+14
-1
@@ -35,8 +35,18 @@ fi
|
|||||||
source .includes/functions.sh
|
source .includes/functions.sh
|
||||||
source .includes/ui.sh
|
source .includes/ui.sh
|
||||||
|
|
||||||
|
copyparty_installed() {
|
||||||
|
pacman -Q copyparty &> /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
choice="$(menulist "Firewall" "MiniDLNA" "Mumble Server" "Nginx" "Top Speed Server" "Top Speed Console" "Copyparty" "Exit")" || break
|
menuOptions=("Firewall" "MiniDLNA" "Mumble Server" "Nginx" "Top Speed Server" "Top Speed Console" "Copyparty")
|
||||||
|
if copyparty_installed; then
|
||||||
|
menuOptions+=("Show Copyparty Address")
|
||||||
|
fi
|
||||||
|
menuOptions+=("Exit")
|
||||||
|
|
||||||
|
choice="$(menulist "${menuOptions[@]}")" || break
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
"Firewall")
|
"Firewall")
|
||||||
source .includes/firewall.sh
|
source .includes/firewall.sh
|
||||||
@@ -59,6 +69,9 @@ while true; do
|
|||||||
"Copyparty")
|
"Copyparty")
|
||||||
source .includes/copyparty.sh
|
source .includes/copyparty.sh
|
||||||
;;
|
;;
|
||||||
|
"Show Copyparty Address")
|
||||||
|
source .includes/copyparty.sh show-address
|
||||||
|
;;
|
||||||
"Exit")
|
"Exit")
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user