Пример #1
0
    os.system("mkdir -p /etc/apt/keyrings")
    os.system(
        "curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/debian/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg"
    )
    os.system(
        'echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.ustc.edu.cn/docker-ce/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null'
    )
    os.system("apt update; apt install -y docker-ce")
    current_dir = os.path.dirname(os.path.abspath(__file__))
    cmd = "cp -rf %s/docker/daemon.json /etc/docker/daemon.json" % (
        current_dir)
    os.system(cmd)


if __name__ == "__main__":
    if False == proc.is_root():
        print("This program must be run as root. Aborting.")
        exit(-1)

    script_name = str(sys.argv[0])
    if len(sys.argv) < 2:
        print("用法: %s aliyun/ustc" % (script_name))
        exit(-1)

    mirror_name = str(sys.argv[1])
    add_usr_sbin_to_path_env()
    disable_root_history()
    make_colorful_ls()
    set_swapping_config()
    set_fs_watches_config()
    set_mirror_apt_config(mirror_name)
Пример #2
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

from __future__ import print_function

import os
import sys

pwd = os.path.dirname(os.path.abspath(__file__))
module_path = "%s/../../" % pwd
sys.path.append(module_path)
from py_mods import file
from py_mods import proc

if __name__ == "__main__":
    if True == proc.is_root():
        print("This program can not be run as root. Aborting.")
        exit(-1)

    os.system("curl https://pyenv.run | bash")

    path = os.path.expanduser("~")
    profile = path + "/" + ".profile"
    is_in_profile = file.is_in_file(profile, 'eval "$(pyenv init --path)"')
    if False == is_in_profile:
        os.system("echo '' >> ~/.profile")
        os.system("echo export PYENV_ROOT='\"$HOME/.pyenv\"' >> ~/.profile")
        os.system("echo export PATH='\"$PYENV_ROOT/bin:$PATH\"' >> ~/.profile")
        os.system("echo eval '\"$(pyenv init --path)\"' >> ~/.profile")
        os.system("echo eval '\"$(pyenv virtualenv-init -)\"' >> ~/.profile")