|
| 1 | +package apt |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + "github.com/linuxsuren/http-downloader/pkg/exec" |
| 6 | + "runtime" |
| 7 | +) |
| 8 | + |
| 9 | +// ffmpegInstallerInUbuntu is the installer of ffmpeg in CentOS |
| 10 | +type ffmpegInstallerInUbuntu struct { |
| 11 | + count int |
| 12 | +} |
| 13 | + |
| 14 | +// Available check if support current platform |
| 15 | +func (d *ffmpegInstallerInUbuntu) Available() (ok bool) { |
| 16 | + if runtime.GOOS == "linux" { |
| 17 | + _, err := exec.LookPath("apt-get") |
| 18 | + ok = err == nil |
| 19 | + } |
| 20 | + return |
| 21 | +} |
| 22 | + |
| 23 | +// Install installs the ffmpeg |
| 24 | +func (d *ffmpegInstallerInUbuntu) Install() (err error) { |
| 25 | + if err = exec.RunCommand("apt-get", "update", "-y"); err != nil { |
| 26 | + return |
| 27 | + } |
| 28 | + if err = exec.RunCommand("apt-get", "install", "-y", |
| 29 | + "ffmpeg"); err != nil { |
| 30 | + return |
| 31 | + } |
| 32 | + return |
| 33 | +} |
| 34 | + |
| 35 | +// Uninstall uninstalls the ffmpeg |
| 36 | +func (d *ffmpegInstallerInUbuntu) Uninstall() (err error) { |
| 37 | + err = exec.RunCommand("apt-get", "remove", "-y", |
| 38 | + "ffmpeg") |
| 39 | + return |
| 40 | +} |
| 41 | + |
| 42 | +// WaitForStart waits for the service be started |
| 43 | +func (d *ffmpegInstallerInUbuntu) WaitForStart() (ok bool, err error) { |
| 44 | + ok = true |
| 45 | + return |
| 46 | +} |
| 47 | + |
| 48 | +// Start starts the ffmpeg service |
| 49 | +func (d *ffmpegInstallerInUbuntu) Start() error { |
| 50 | + fmt.Println("not supported yet") |
| 51 | + return nil |
| 52 | +} |
| 53 | + |
| 54 | +// Stop stops the ffmpeg service |
| 55 | +func (d *ffmpegInstallerInUbuntu) Stop() error { |
| 56 | + fmt.Println("not supported yet") |
| 57 | + return nil |
| 58 | +} |
0 commit comments