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() {
|
||||
local detectedSubnet=""
|
||||
local subnetChoice=""
|
||||
@@ -433,22 +467,50 @@ configure_copyparty_firewall() {
|
||||
return 0
|
||||
}
|
||||
|
||||
serviceUser="$(choose_copyparty_user)" || return 1
|
||||
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
|
||||
}
|
||||
install_copyparty_flow() {
|
||||
local serviceUser=""
|
||||
local unitName=""
|
||||
local accountsFile=""
|
||||
local usernamesCsv=""
|
||||
local sharesFile=""
|
||||
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"
|
||||
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
|
||||
configure_copyparty_firewall || return 1
|
||||
|
||||
msgbox "Copyparty is configured. For advanced tuning, edit ${copypartyConfigFile} as root."
|
||||
case "${1:-install}" in
|
||||
install)
|
||||
install_copyparty_flow
|
||||
;;
|
||||
show-address)
|
||||
show_copyparty_address
|
||||
;;
|
||||
*)
|
||||
msgbox "Unknown Copyparty action: ${1}"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
|
||||
Reference in New Issue
Block a user