package controller

import (
	"errors"
	"netease_control_center/interfaces/log"
	"netease_control_center/nembd"
	"os"
)

func AfterStarupConnectInternet() (string, error) {
	shname := "/mnt/UDISK/cctest.sh"
	if fileinfo, fileerr := os.Stat(shname); fileerr == nil || os.IsExist(fileerr) {
		os.Chmod(shname, 0777)
		log.Println(log.DebugLog, "Begin to exec:", shname)
		out, outerr := nembd.ExecOutput("sh", shname)
		log.Println(log.DebugLog, "Exec output:", out, outerr)
		return "path:" + shname + " output:" + out, nil
	} else {
		log.Println(log.DebugLog, "No sh to exec", fileinfo, fileerr)
		return "", errors.New("No sh to exec!")
	}
}
