日度归档:2017-04-09

ubuntu中创建程序为自启动

#!/bin/bash
### BEGIN INIT INFO
# Provides:          appname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: appinfo
# Description:       appinfo
### END INIT INFO

bin="/home/user/app"

start(){
  ps -ef | grep $bin | grep -v grep > /dev/null
  if [ $? -eq 0 ]; then
    echo "The Service has started."
  else
    echo -n "Starting..."
    $bin 1>/dev/null 2>/dev/null &
    echo "Done!"
  fi
}

stop(){
  ps -ef | grep $bin | grep -v grep > /dev/null
  if [ $? -eq 0 ]; then
    echo -n "Stoping..."
    killall $bin
    echo "Done!"
  else
    echo "The service did not start."
  fi
}

case $1 in
start)
  start
;;
stop)
  stop
;;
status)
  ps -ef | grep $bin | grep -v grep > /dev/null
  if [ $? -eq 0 ]; then
    echo "The service is running."
  else
    echo "The service is not running."
  fi
;;
*)
  echo "Usage: $0 {start|stop|status}"
;;
esac

脚本放在 /etc/init.d/ 目录下,添加 执行 权限。

# 添加到服务
sudo systemctl enable app  # app 是服务文件名
# 启动服务
sudo service app start

继续阅读

ubuntu 安装 gnome3

安装之前先添加库并更新,已保证后面的安装顺利。

建议在服务器版安装。utility版可以不安装gdm。

sudo add-apt-repository ppa:gnome3-team/gnome3
sudo add-apt-repository ppa:gnome3-team/gnome3-staging
sudo apt-get update
sudo apt-get dist-upgrade -y
sudo apt-get install gdm gnome-shell gnome-shell-extensions gnome-tweak-tool ubuntu-gnome-desktop

继续阅读