Skip to content

Commit

Permalink
[fix]:修复nodejs权限 bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fishros committed Feb 6, 2022
1 parent 0189a9c commit c015a9a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

*.pyc
10 changes: 9 additions & 1 deletion install.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
4: {'tip':'一键配置:ROS环境(快速更新ROS环境设置,自动生成环境选择)', 'type':2, 'tool':url_prefix+'tools/tool_config_rosenv.py' ,'dep':[] },
5: {'tip':'一键配置:系统源(更换系统源,支持全版本Ubuntu系统)', 'type':2, 'tool':url_prefix+'tools/tool_config_system_source.py' ,'dep':[] },
6: {'tip':'一键安装:nodejs开发环境(通过nodejs可以预览小鱼官网噢)', 'type':0, 'tool':url_prefix+'tools/tool_install_nodejs.py' ,'dep':[] },
77: {'tip':'测试模式:运行自定义工具测试'},
}


Expand Down Expand Up @@ -61,8 +62,15 @@ def main():
for tool_id in tools.keys(): choose_dic[tool_id] = tools[tool_id]["tip"]
code,result = ChooseTask(choose_dic, "---众多工具,等君来用---").run()
if code==0: PrintUtils().print_success("是觉得没有合胃口的菜吗?那快联系的小鱼增加菜单吧~")
elif code==77:
code,result = ChooseTask(choose_dic, "请选择你要测试的程序:").run()
if code<0 and code>=77: return False
# CmdTask("cp tools/* /tmp/fishinstall/tools/").run
run_tool_file(tools[code]['tool'].replace(url_prefix,'').replace("/","."))

else:
download_tools(code,tools)
run_tool_file(tools[code]['tool'].replace(url_prefix,'').replace("/","."))

main()
if __name__=='__main__':
main()
Empty file added test_tools.py
Empty file.
10 changes: 10 additions & 0 deletions tools/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,16 @@ def getbashrc():
if bashrc_result[0]!=0: bashrc_result = CmdTask("ls /root/.bashrc", 0).run()
return bashrc_result[1]

@staticmethod
def getusers():
"""
优先home,没有home提供root
"""
users = CmdTask("users", 0).run()
if users[0]!=0: return ['root']
return users[1]


@staticmethod
def new(path,name=None,data=''):
if not os.path.exists(path):
Expand Down
3 changes: 2 additions & 1 deletion tools/tool_install_nodejs.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ def install_nodejs(self):
CmdTask("rm -rf /opt/nodejs/").run()
CmdTask("mkdir -p /opt/nodejs/").run()
CmdTask("sudo tar -xvf /tmp/nodejs.tar.xz -C /opt/nodejs/").run()
CmdTask("sudo chmod -R 777 /opt/nodejs/").run()
CmdTask("rm -rf /tmp/nodejs.tar.xz").run()
PrintUtils.print_info("解压完成,接下来为你配置nodejs环境~")
# 配置环境
for bashrc in FileUtils.getbashrc()+['/root/.bashrc']:
for bashrc in FileUtils.getbashrc():
FileUtils.find_replace_sub(bashrc,"# >>> nodejs initialize >>>","# <<< nodejs initialize <<<", "")
FileUtils.append(bashrc,"# >>> nodejs initialize >>>\n"+"export PATH=$PATH:/opt/nodejs/node-v16.13.2-linux-x64/bin/"+"\n# <<< nodejs initialize <<<")
PrintUtils.print_info("配置完成,接下来你可以尝试使用node和npm指令运行了~")
Expand Down

0 comments on commit c015a9a

Please sign in to comment.