File tree Expand file tree Collapse file tree 2 files changed +36
-3
lines changed
Expand file tree Collapse file tree 2 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -97,6 +97,39 @@ Use "egpu-switcher [command] --help" for more information about a command.
9797
9898---
9999
100+ ## Configuration
101+
102+ The config file is created automatically and can be found at ` /etc/egpu-switcher/config.yaml ` .
103+ Below you can see an example of a configuration file, annotated with some notes.
104+
105+ ``` yaml
106+ # the 'egpu' config is generated by 'egpu-switcher config'.
107+ # you probably shouldn't change this manually.
108+ egpu :
109+ driver : amdgpu
110+ id : 1153611719250962689
111+
112+ # OPTIONAL: how many times 'egpu-switcher switch auto' should retry finding the egpu.
113+ # this can be helpful if the egpu takes some time to connect on your machine,
114+ # the following values are the default, if this config is omitted.
115+ detection :
116+ retries : 6
117+ interval : 500 # milliseconds
118+
119+ # OPTIONAL: if you want to execute a script after switching to egpu/internal.
120+ # the values must be absolute paths to a shell script, this script will
121+ # then be run with '/bin/sh $script'.
122+ #
123+ # it is required that the script is owned by root (uid 0)
124+ # and has a permission of -rwx------ (0700), in order to
125+ # prevent potential privilege escalation.
126+ hooks :
127+ internal : /home/michael/tmp/internal.sh
128+ egpu : /home/michael/tmp/egpu.sh
129+ ` ` `
130+
131+ ---
132+
100133## Troubleshooting
101134
102135If you run into problems, please have a look at
Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ func switchInternal() error {
154154 }
155155 if post := viper .GetString ("hooks.internal" ); post != "" {
156156 if err := runHook (post ); err != nil {
157- logger .Error ("egpu hook error: %s" , err )
157+ logger .Error ("internal hook error: %s" , err )
158158 }
159159 }
160160 return nil
@@ -174,7 +174,7 @@ func switchAuto(gpu *pci.GPU) error {
174174
175175func runHook (script string ) error {
176176 if ! permissionCheck (script ) {
177- return fmt .Errorf ("hook scripts need to be sufficiently protected because they are run as root" )
177+ return fmt .Errorf ("hook %s will not be executed" , script )
178178 }
179179 cmd := exec .Command ("/bin/sh" , script )
180180 err := cmd .Run ()
@@ -187,7 +187,7 @@ func runHook(script string) error {
187187func permissionCheck (file string ) bool {
188188 info , err := os .Stat (file )
189189 if err != nil {
190- logger .Debug ( "unable to get info about %s: %s" , file , err )
190+ logger .Error ( "%s" , err )
191191 return false
192192 }
193193 if stat , ok := info .Sys ().(* syscall.Stat_t ); ok {
You can’t perform that action at this time.
0 commit comments