Simplify shell command execution
parent
4b7de8e14b
commit
c17c4de9b0
|
@ -145,7 +145,7 @@ func printSettings(ser *settings.Server, set *settings.Settings, auther auth.Aut
|
|||
fmt.Fprintf(w, "Sign up:\t%t\n", set.Signup)
|
||||
fmt.Fprintf(w, "Create User Dir:\t%t\n", set.CreateUserDir)
|
||||
fmt.Fprintf(w, "Auth method:\t%s\n", set.AuthMethod)
|
||||
fmt.Fprintf(w, "Shell:\t%s\t\n", strings.Join(set.Shell, " "))
|
||||
fmt.Fprintf(w, "Shell:\t%s\t\n", set.Shell)
|
||||
fmt.Fprintln(w, "\nBranding:")
|
||||
fmt.Fprintf(w, "\tName:\t%s\n", set.Branding.Name)
|
||||
fmt.Fprintf(w, "\tFiles override:\t%s\n", set.Branding.Files)
|
||||
|
|
|
@ -32,7 +32,7 @@ override the options.`,
|
|||
Key: generateKey(),
|
||||
Signup: mustGetBool(flags, "signup"),
|
||||
CreateUserDir: mustGetBool(flags, "create-user-dir"),
|
||||
Shell: convertCmdStrToCmdArray(mustGetString(flags, "shell")),
|
||||
Shell: mustGetString(flags, "shell"),
|
||||
AuthMethod: authMethod,
|
||||
Defaults: defaults,
|
||||
Branding: settings.Branding{
|
||||
|
|
|
@ -48,7 +48,7 @@ you want to change. Other options will remain unchanged.`,
|
|||
case "auth.method":
|
||||
hasAuth = true
|
||||
case "shell":
|
||||
set.Shell = convertCmdStrToCmdArray(mustGetString(flags, flag.Name))
|
||||
set.Shell = mustGetString(flags, flag.Name)
|
||||
case "create-user-dir":
|
||||
set.CreateUserDir = mustGetBool(flags, flag.Name)
|
||||
case "branding.name":
|
||||
|
|
|
@ -344,7 +344,7 @@ func quickSetup(flags *pflag.FlagSet, d pythonData) {
|
|||
RetryCount: settings.DefaultTusRetryCount,
|
||||
},
|
||||
Commands: nil,
|
||||
Shell: nil,
|
||||
Shell: "",
|
||||
Rules: nil,
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ interface ISettings {
|
|||
rules: any[];
|
||||
branding: SettingsBranding;
|
||||
tus: SettingsTus;
|
||||
shell: string[];
|
||||
shell: string;
|
||||
commands: SettingsCommand;
|
||||
}
|
||||
|
||||
|
|
|
@ -296,12 +296,7 @@ const save = async () => {
|
|||
if (settings.value === null) return false;
|
||||
let newSettings: ISettings = {
|
||||
...settings.value,
|
||||
shell:
|
||||
settings.value?.shell
|
||||
.join(" ")
|
||||
.trim()
|
||||
.split(" ")
|
||||
.filter((s: string) => s !== "") ?? [],
|
||||
shell: settings.value?.shell?.trim() ?? "", // Change this to a string
|
||||
commands: {},
|
||||
};
|
||||
|
||||
|
@ -309,7 +304,6 @@ const save = async () => {
|
|||
keyof SettingsCommand
|
||||
>;
|
||||
for (const key of keys) {
|
||||
// not sure if we can safely assume non-null
|
||||
const newValue = commandObject.value[key];
|
||||
if (!newValue) continue;
|
||||
|
||||
|
@ -321,7 +315,9 @@ const save = async () => {
|
|||
.filter((cmd: string) => cmd !== "");
|
||||
}
|
||||
}
|
||||
newSettings.shell = shellValue.value.split("\n");
|
||||
|
||||
// Update this line to assign the string directly, without splitting
|
||||
newSettings.shell = shellValue.value.trim();
|
||||
|
||||
if (newSettings.branding.theme !== getTheme()) {
|
||||
setTheme(newSettings.branding.theme);
|
||||
|
@ -386,7 +382,7 @@ onMounted(async () => {
|
|||
|
||||
originalSettings.value = original;
|
||||
settings.value = newSettings;
|
||||
shellValue.value = newSettings.shell.join("\n");
|
||||
shellValue.value = newSettings.shell;
|
||||
} catch (err) {
|
||||
if (err instanceof Error) {
|
||||
error.value = err;
|
||||
|
|
|
@ -16,7 +16,7 @@ type settingsData struct {
|
|||
Rules []rules.Rule `json:"rules"`
|
||||
Branding settings.Branding `json:"branding"`
|
||||
Tus settings.Tus `json:"tus"`
|
||||
Shell []string `json:"shell"`
|
||||
Shell string `json:"shell"`
|
||||
Commands map[string][]string `json:"commands"`
|
||||
}
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ func tusPatchHandler() handleFunc {
|
|||
|
||||
w.Header().Set("Upload-Offset", strconv.FormatInt(uploadOffset+bytesWritten, 10))
|
||||
|
||||
if bytesWritten < int64(d.Settings.Tus.ChunkSize) {
|
||||
if uint64(bytesWritten) < (d.Settings.Tus.ChunkSize) {
|
||||
err = d.RunAfterHook("upload", r.URL.Path, "", d.user)
|
||||
if err != nil {
|
||||
return errToStatus(err), err
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
func ParseCommand(s *settings.Settings, raw string) ([]string, error) {
|
||||
var command []string
|
||||
|
||||
if len(s.Shell) == 0 || s.Shell[0] == "" {
|
||||
if s.Shell == "" {
|
||||
cmd, args, err := SplitCommandAndArgs(raw)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -26,7 +26,7 @@ func ParseCommand(s *settings.Settings, raw string) ([]string, error) {
|
|||
command = append(command, cmd)
|
||||
command = append(command, args...)
|
||||
} else {
|
||||
cmd, args, err := SplitCommandAndArgs(s.Shell[0])
|
||||
cmd, args, err := SplitCommandAndArgs(s.Shell)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ type Settings struct {
|
|||
Branding Branding `json:"branding"`
|
||||
Tus Tus `json:"tus"`
|
||||
Commands map[string][]string `json:"commands"`
|
||||
Shell []string `json:"shell"`
|
||||
Shell string `json:"shell"`
|
||||
Rules []rules.Rule `json:"rules"`
|
||||
}
|
||||
|
||||
|
|
|
@ -72,8 +72,8 @@ func (s *Storage) Save(set *Settings) error {
|
|||
set.Rules = []rules.Rule{}
|
||||
}
|
||||
|
||||
if set.Shell == nil {
|
||||
set.Shell = []string{}
|
||||
if set.Shell == "" {
|
||||
set.Shell = ""
|
||||
}
|
||||
|
||||
if set.Commands == nil {
|
||||
|
|
Loading…
Reference in New Issue